From 96f570035d6353c421164329d3d022773ec894f1 Mon Sep 17 00:00:00 2001 From: mail Date: Sat, 6 Oct 2007 00:25:40 +0200 Subject: EwmhDesktops initial patch What works so far, quit hackerish: * Number of Workspaces * Active current workspace * Names of workspaces More to come.. darcs-hash:20071005222540-c9905-33f19902bbe804a7dc4eccba27fed43822f55dd1.gz --- EwmhDesktops.hs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 EwmhDesktops.hs diff --git a/EwmhDesktops.hs b/EwmhDesktops.hs new file mode 100644 index 0000000..d6684ac --- /dev/null +++ b/EwmhDesktops.hs @@ -0,0 +1,42 @@ +module XMonadContrib.EwmhDesktops (ewmhDesktopsLogHook) where + +import Data.Maybe (listToMaybe,fromJust) +import Data.List (elemIndex, sortBy) +import Data.Ord ( comparing) + +import Control.Monad.Reader +import XMonad +import qualified StackSet as W +import System.IO +import Graphics.X11.Xlib +import Graphics.X11.Xlib.Extras + +ewmhDesktopsLogHook :: X () +ewmhDesktopsLogHook = withDisplay $ \dpy -> withWindowSet $ \s -> do + -- Number of Workspaces + -- Bad hack because xmonad forgets the original order of things, it seems + let ws = sortBy (comparing W.tag) $ W.workspaces s + + let n = fromIntegral (length ws) + a <- getAtom "_NET_NUMBER_OF_DESKTOPS" + c <- getAtom "CARDINAL" + r <- asks theRoot + io $ changeProperty32 dpy r a c propModeReplace [n] + + -- Names thereof + a <- getAtom "_NET_DESKTOP_NAMES" + c <- getAtom "UTF8_STRING" + let names = map (fromIntegral.fromEnum) $ + concatMap (("Workspace "++) . (++['\0']). W.tag) ws + io $ changeProperty8 dpy r a c propModeReplace names + + -- Current desktop + a <- getAtom "_NET_CURRENT_DESKTOP" + c <- getAtom "CARDINAL" + let Just n = W.lookupWorkspace 0 s + let Just i = elemIndex n $ map W.tag ws + io $ changeProperty32 dpy r a c propModeReplace [fromIntegral i] + + return () + + -- cgit v1.2.3