Doing a “Show Desktop” using Python’s libwnck bindings
Quick tip: you can do a Show Desktop from a script (from Python, in this case), with:
python -c "import gtk,wnck,gobject; s=wnck.screen_get_default(); s.toggle_showing_desktop(True); gobject.idle_add(gtk.main_quit); gtk.main()"
Interesting; I’d not seen wnck - does it allow you to show windows fullscreen without menus, etc?
11 hours later
mrben: wnck is an interface to the window manager, essentially. It’s what the pager uses to know where windows are and so on. I’m not sure if it lets you alter an existing window; devilspie does that, but I don’t know if it uses libwnck.
12 hours later
mrben, sil: It seems that wnck can do that (or at least its API has the corresponding functions ;-)). It looks equivalent to devilspie, or slighly more detailed (e.g. for viewport).
It works ONLY if you have called gtk.main(), e.g. :
def run():
print wnck.screen_get_default().get_windows()
# do your job here
gtk.main_quit()
gobject.idle_add(run)
gtk.main()
18 weeks later
Well, I the code provided by jiba. But, I got none windows:
leon@localhost ~/tmp_python $ python wm.max.py
[]
Why ? But, the “Show Desktop” code works.
32 weeks later
Hi, where i can find tha API for the libwnck python module ??
38 weeks later
Manuel,
Trying to build sugar I presume? I’m looking for it as well.
38 weeks later
Sugar ? what is ?
38 weeks later
You need to run force_update() on the screen before pulling anything from it. If you run that before get_windows() it all works OK! :)
51 weeks later