Changing wallpaper in python

I am running Maverick on my machine and I am trying to write a script to change wallpaper in python. So far, my progress.

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 clean wallpaper. He shows me a white screen.

I looked at the file gcnonf.xmland the change was made there.

Can anybody help me?

+3
source share
1 answer

The problem is probably what you are missing /in the beginning home/tsudot/Pictures/zombie.jpg, so the file was not found. To avoid this problem in the future, you could change your code to save the file name in a variable and check before trying to set the configuration parameter that this file exists with os.path.exists(filename).

+6
source

Source: https://habr.com/ru/post/1794103/


All Articles