How can I have my python program ask the system what the desktop background image is/or where it is?
How can I have my python program ask the system what the desktop background image is/or where it is?
Last edited by OgreProgrammer; January 23rd, 2010 at 10:35 AM.
You could try and parse $HOME/.gnome2/backgrounds.xml
It would appear to contain a list of background-images
___________ . . ___________
"An expert is a person who has made all the mistakes that can be made in a very narrow field" -Nils Bohr
or you could use gnome's own tool to find out
gconftool-2 --get /desktop/gnome/background/picture_filename
___________ . . ___________
"An expert is a person who has made all the mistakes that can be made in a very narrow field" -Nils Bohr
This code comes from Davyd Madeley's change-background.py script:
Code:import gconf class GConfClient: def __init__ (self): self.__client__ = gconf.client_get_default () def get_background (self): return self.__client__.get_string("/desktop/gnome/background/picture_filename") def set_background (self, background): self.__client__.set_string ( "/desktop/gnome/background/picture_filename", background) client = GConfClient () print(client.get_background())
Thanks unutbu and denarced. That was exactly what i needed.
Is there also some way for a window to know where it has been placed at after the mouse moves it?
Last edited by OgreProgrammer; January 25th, 2010 at 04:20 AM.
Using gnome (gtk) you can determine the position of the window with gtk.Window.get_position().
Take a look at www.pygtk.org for the python docs on gtk, but be warned there is a brickload of docs to dive into!
Not sure if there are other methods to find this out, if there are I'm interested aswell.
Bookmarks