ENH revert failed last two commits

This commit is contained in:
Nathan Dwarshuis 2024-01-07 11:49:30 -05:00
parent 04c430efc6
commit a963be1421
1 changed files with 7 additions and 10 deletions

View File

@ -34,14 +34,18 @@ import UnliftIO.Environment
main :: IO () main :: IO ()
main = runSimpleApp $ do main = runSimpleApp $ do
r <- getMonitorName
args <- getArgs args <- getArgs
pre <- maybe [] (\n -> ["-m", T.unpack n]) <$> getMonitorName let allArgs = maybe [] (\n -> ["-m", T.unpack n] ++ args) r
exitWith =<< proc "/usr/bin/rofi" (pre ++ args) runProcess c <- proc "/usr/bin/rofi" allArgs runProcess
exitWith c
data Coord = Coord Int Int deriving (Eq, Show) data Coord = Coord Int Int deriving (Eq, Show)
-- TODO bracket this
getMonitorName :: MonadIO m => m (Maybe T.Text) getMonitorName :: MonadIO m => m (Maybe T.Text)
getMonitorName = liftIO $ withOpenDisplay $ \dpy -> do getMonitorName = liftIO $ do
dpy <- openDisplay ""
root <- rootWindow dpy $ defaultScreen dpy root <- rootWindow dpy $ defaultScreen dpy
index <- getCurrentDesktopIndex dpy root index <- getCurrentDesktopIndex dpy root
viewports <- getDesktopViewports dpy root viewports <- getDesktopViewports dpy root
@ -93,10 +97,3 @@ getAtom32 dpy root str = do
a <- internAtom dpy (T.unpack str) False a <- internAtom dpy (T.unpack str) False
p <- getWindowProperty32 dpy a root p <- getWindowProperty32 dpy a root
return $ maybe [] (fmap fromIntegral) p return $ maybe [] (fmap fromIntegral) p
withOpenDisplay :: MonadUnliftIO m => (Display -> m a) -> m a
withOpenDisplay = bracket (liftIO $ openDisplay "") cleanup
where
cleanup dpy = liftIO $ do
flush dpy
closeDisplay dpy