Just a python script, to print the name of the current desktop. Could be useful to pipe to conky or something.
#!/usr/bin/env python
from Xlib import display, Xatom
dsp = display.Display()
rootwin = dsp.screen().root
DESKTOP_NAMES = dsp.intern_atom("_NET_DESKTOP_NAMES")
CURRENT_DESKTOP = dsp.intern_atom("_NET_CURRENT_DESKTOP")
def get_names():
names = rootwin.get_full_property(DESKTOP_NAMES, 0)
names = names.value.split("\x00")
return names
def current_desktop():
return rootwin.get_full_property(CURRENT_DESKTOP,
Xatom.CARDINAL
).value[0]
try:
print get_names()[current_desktop()]
except:
print "error getting name"
Requires the python bindings for xlib

No comments yet
Comments feed for this article