I need the information about the current workspace/screen from Xmonad. I need it externally in a bash script so that I can perform some function based on the current workspace where I am in.
I searched the web and it seems like dynamicLog is one of the way to do this. But am not able to figure out how exactly to send the information from Xmonad into a file. What I am trying to do is that make Xmonad update a certain file with the current workspace information whenever it changes.
Can this be done through DynamicLogger?
My current Xmonad dynamicLog section is as follows:
, logHook = dynamicLogWithPP
xmobarPP
{ ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor "darkgreen" "" . shorten 100
}
Alternatively, looking at another method on the web, I tried something like
.
.
.
import XMonad.Hooks.SetWMName
import XMonad.Hooks.EwmhDesktops
import XMonad.Util.Cursor
myStartupHook = do
startupHook gnomeConfig
-- spawn "xcompmgr -cfC -t-9 -l-11 -r9 -D6 &"
setDefaultCursor xC_left_ptr <+> ewmhDesktopsStartup >> setWMName "Xmonad"
.
.
.
...to be used for the utility wmctrl but it did not work. Its output was like -
$ wmctrl -d
Cannot get number of desktops properties. (_NET_NUMBER_OF_DESKTOPS or _WIN_WORKSPACE_COUNT)
Any help on any of the above is appreciated.
Thanks
xprop utility is probably what you're looking for. To my knowledge, it works with every window manager, including XMonad. It provides information about desktops, windows and bunch of other stuff on X11. Here's example of it's output on my system:
You can also specify which properties you want to get:
It behaves the same way with windows, which you might find useful for finding out which desktops are being occupied:
Manual page for xprop contains some more useful flags, so make sure to check it.