summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrent Yorgey <byorgey@gmail.com>2008-03-25 15:54:14 +0100
committerBrent Yorgey <byorgey@gmail.com>2008-03-25 15:54:14 +0100
commit617a0b99e3b59406bf1b73e2c7f679ab5877c2ef (patch)
treef14d5ce31cca33bc68b64f976d7914ff4d4270f4
parent30e75ac8bd16e4addd33c20b2d956753606272a7 (diff)
downloadmetatile-617a0b99e3b59406bf1b73e2c7f679ab5877c2ef.tar
metatile-617a0b99e3b59406bf1b73e2c7f679ab5877c2ef.zip
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
-rw-r--r--XMonad/ManageHook.hs12
1 files changed, 12 insertions, 0 deletions
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