From 617a0b99e3b59406bf1b73e2c7f679ab5877c2ef Mon Sep 17 00:00:00 2001 From: Brent Yorgey Date: Tue, 25 Mar 2008 15:54:14 +0100 Subject: ManageHook: add a 'property' Query that can get an arbitrary String property from a window (such as WM_WINDOW_ROLE, for example) darcs-hash:20080325145414-bd4d7-c7aee8e7ee691e4a75a88451762472db63aa6e45 --- XMonad/ManageHook.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/XMonad/ManageHook.hs b/XMonad/ManageHook.hs index 072fe1f..b4996b2 100644 --- a/XMonad/ManageHook.hs +++ b/XMonad/ManageHook.hs @@ -20,6 +20,7 @@ module XMonad.ManageHook where import XMonad.Core import Graphics.X11.Xlib.Extras +import Graphics.X11.Xlib (Display,Window) import Control.Monad.Reader import Data.Maybe import Data.Monoid @@ -65,6 +66,17 @@ title = ask >>= (\w -> liftX $ withDisplay $ \d -> fmap (fromMaybe "") $ io resource = ask >>= (\w -> liftX $ withDisplay $ \d -> fmap resName $ io $ getClassHint d w) className = ask >>= (\w -> liftX $ withDisplay $ \d -> fmap resClass $ io $ getClassHint d w) +-- | A query that can return an arbitrary X property of type String, +-- identified by name. +property :: String -> Query String +property p = ask >>= (\w -> liftX $ withDisplay $ \d -> fmap (fromMaybe "") $ getProperty d w p) + +getProperty :: Display -> Window -> String -> X (Maybe String) +getProperty d w p = do + a <- getAtom p + md <- io $ getWindowProperty8 d a w + return $ fmap (map (toEnum . fromIntegral)) md + -- | Modify the 'WindowSet' with a pure function. doF :: (WindowSet -> WindowSet) -> ManageHook doF = return . Endo -- cgit v1.2.3