3

I'm running a Maverick on my machine, and I'm trying to write a script to change wallpapers in python. Heres my progress so far.

import gconf
client = gconf.client_get_default()
current_bg = client.get_string("/desktop/gnome/background/picture_filename")
client.set_string("/desktop/gnome/background/picture_filename","home/tsudot/Pictures/zombie.jpg")

After running the script I get a blank wallpaper. It shows me a white screen.

I examined the gcnonf.xml file and the change has been made there.

Can anybody help me out?

tsudot
  • 533
  • 1
  • 6
  • 16

1 Answers1

6

The problem is probably that you're missing a / at the beginning of home/tsudot/Pictures/zombie.jpg so the file isn't found. To avoid this problem happening in the future, you could perhaps change your code to keep the filename in a variable and check before trying to set the config option that that file exists with os.path.exists(filename).

Mark Longair
  • 446,582
  • 72
  • 411
  • 327
  • oh turns out I had the / in the original code. Just a typo here! :D but filepath had problems – tsudot Feb 23 '11 at 11:18
  • no problem - I hadn't realized it was so simple to set a new background programmatically, in fact, so I like the question :) – Mark Longair Feb 23 '11 at 11:26