python -c "import gtk,wnck,gobject; s=wnck.screen_get_default(); s.toggle_showing_desktop(True); gobject.idle_add(gtk.main_quit); gtk.main()"
And this is Doing a "Show Desktop" using Python's libwnck bindings, written , and concerning Howtos
Comments
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.
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()
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.
Hi, where i can find tha API for the libwnck python module ??
Manuel,
Trying to build sugar I presume? I'm looking for it as well.
Sugar ? what is ?
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! :)
How do you make the windows restore again with your script? I've been messing around it and can't seem to figure it out. Thanks!
Antonio: Try using s.toggle_showing_desktop(False); ?
Yes, I've tried and it works. But it shows the desktop and then gets the windows back on screen. My goal is to make it show desktop and show windows again if the script is run again. Sorry I'm learning! Thanks!
Interesting; I'd not seen wnck - does it allow you to show windows fullscreen without menus, etc?