Results 1 to 6 of 6

Thread: using python to locate gnome resources

  1. #1
    Join Date
    Apr 2009
    Location
    Canada
    Beans
    157
    Distro
    Ubuntu 10.10 Maverick Meerkat

    using python to locate gnome resources

    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.

  2. #2
    Join Date
    Apr 2008
    Location
    Finland
    Beans
    173
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: using python to locate gnome resources

    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

  3. #3
    Join Date
    Apr 2008
    Location
    Finland
    Beans
    173
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: using python to locate gnome resources

    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

  4. #4
    Join Date
    Mar 2008
    Beans
    4,714
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: using python to locate gnome resources

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

  5. #5
    Join Date
    Apr 2009
    Location
    Canada
    Beans
    157
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: using python to locate gnome resources

    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.

  6. #6
    Join Date
    Feb 2008
    Location
    Norway
    Beans
    39
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: using python to locate gnome resources

    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.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •