aboutsummaryrefslogtreecommitdiffstats
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
commitcd47e45fdec2f9e4a0e69168fa895c60f290d691 (patch)
treef14d5ce31cca33bc68b64f976d7914ff4d4270f4
parent521ebb40591155a4c6c9e0308f05ef1bda19e9c1 (diff)
downloadxmonad-cd47e45fdec2f9e4a0e69168fa895c60f290d691.tar.gz
xmonad-cd47e45fdec2f9e4a0e69168fa895c60f290d691.tar.xz
xmonad-cd47e45fdec2f9e4a0e69168fa895c60f290d691.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.gz
-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