diff options
Diffstat (limited to 'src/main.hs')
-rw-r--r-- | src/main.hs | 44 |
1 files changed, 6 insertions, 38 deletions
diff --git a/src/main.hs b/src/main.hs index 39f5491..2c500c7 100644 --- a/src/main.hs +++ b/src/main.hs @@ -6,7 +6,6 @@ module Main (main) where import Blessings.Text (Blessings(Plain,SGR),pp) -import Control.Applicative ((<|>)) import Control.Concurrent import Control.Monad (forM) import Control.Monad (forever) @@ -37,35 +36,15 @@ import qualified Data.Text.Extra as Text import qualified Data.Text.IO as Text import qualified Data.Text.Read as Text import qualified Graphics.X11 as X11 +import qualified Graphics.X11.EWMH as X11; import qualified Graphics.X11.Extra as X11 import qualified Graphics.X11.Xlib.Extras as X11 -import qualified Graphics.X11.Xlib.Extras.Extra as X11 import qualified Hack.Buffer as Buffer import qualified Hack.Buffer.Extra as Buffer import qualified Pager.Sixelerator as Pager import qualified System.Console.Terminal.Size as Term -getActiveWindow :: X11.Display -> IO (Maybe X11.Window) -getActiveWindow d = - (fmap (fromIntegral . head) <$>) $ - X11.getWindowProperty32 d X11._NET_ACTIVE_WINDOW w - where w = X11.defaultRootWindow d - -getCurrentDesktop :: X11.Display -> IO (Maybe CLong) -getCurrentDesktop d = - (fmap head <$>) $ - X11.getWindowProperty32 d X11._NET_CURRENT_DESKTOP w <|> - X11.getWindowProperty32 d X11._WIN_WORKSPACE w - where w = X11.defaultRootWindow d - -getDesktopNames :: X11.Display -> IO (Maybe [Text]) -getDesktopNames d = do - (fmap (Text.split (=='\NUL')) <$>) $ - X11.getWindowPropertyText d X11._NET_DESKTOP_NAMES w <|> - X11.getWindowPropertyText d X11._WIN_WORKSPACE_NAMES w - where w = X11.defaultRootWindow d - getGeometry :: X11.Display -> X11.Window -> IO Geometry getGeometry d w = do (_, x, y, width, height, _, _) <- X11.getGeometry d w @@ -76,25 +55,14 @@ getGeometry d w = do , geometry_height = fromIntegral height } -getWindowDesktop :: X11.Display -> X11.Window -> IO (Maybe CLong) -getWindowDesktop d w = - (fmap head <$>) $ - X11.getWindowProperty32 d X11._NET_WM_DESKTOP w <|> - X11.getWindowProperty32 d X11._WIN_WORKSPACE w - -getWindowTitle :: X11.Display -> X11.Window -> IO (Maybe Text) -getWindowTitle d w = - X11.getWindowPropertyText d X11._NET_WM_NAME w <|> - X11.getWindowPropertyText d X11._WM_NAME w - getWorkspaces :: X11.Display -> Geometry -> Set X11.Window -> IO [Workspace] getWorkspaces display screenGeometry focusWindows = do let rootWindow = X11.defaultRootWindow display - currentDesktop <- fromMaybe 0 <$> getCurrentDesktop display + currentDesktop <- fromMaybe 0 <$> X11.getCurrentDesktop display workspaces <- do - names <- zip [0..] . fromMaybe [] <$> getDesktopNames display + names <- zip [0..] . fromMaybe [] <$> X11.getDesktopNames display ws <- forM names $ \(index, name) -> do return Workspace @@ -111,8 +79,8 @@ getWorkspaces display screenGeometry focusWindows = do let f w = do - title <- getWindowTitle display w - desktop <- fromMaybe 0 <$> getWindowDesktop display w + title <- X11.getWindowTitle display w + desktop <- fromMaybe 0 <$> X11.getWindowDesktop display w geometry <- getGeometry display w wm_hints <- X11.getWMHints display w @@ -173,7 +141,7 @@ main = do error $ "bad arguments: " <> show args - Just activeWindow <- X11.withDefaultDisplay getActiveWindow + Just activeWindow <- X11.withDefaultDisplay X11.getActiveWindow screenGeometry <- X11.withDefaultDisplay $ \display -> do |