This is as days pass by, by Stuart Langridge

And this is Doing a "Show Desktop" using Python's libwnck bindings, written , and concerning Howtos

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()"

Comments

mrben

Interesting; I'd not seen wnck - does it allow you to show windows fullscreen without menus, etc?

sil

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.

jiba

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()

Leon

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.

Manuel Mazzuola

Hi, where i can find tha API for the libwnck python module ??

bj

Manuel,

Trying to build sugar I presume? I'm looking for it as well.

Manuel

Sugar ? what is ?

mibus

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! :)

António Lima

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!

sil

Antonio: Try using s.toggle_showing_desktop(False); ?

António Lima

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!

This website belongs to Stuart Langridge. Contact details are available. Don't eat yellow snow. Valid HTML5, at least in theory, except for the bits that aren't because I'm that futuristic that I'm ahead of the spec, oh yes. HTML5 help from Bruce Lawson, among others. Fonts from the superb FontSquirrel. End.