Note that there are some explanatory texts on larger screens.

plurals
  1. POAutomatic background changer using Python 2.7.3 not working, though it should
    primarykey
    data
    text
    <p>I'm very new to Ubuntu/Python/Bash/Gnome in general, so I still feel like there's a chance I'm doing something wrong, but it's been 3 days now without success...</p> <p>Here's what the script is supposed to do:<br> * [✓] Download 1 random image from wallbase.cc<br> * [✓] Save it to the same directory that the script is running from<br> * [x] Set it as the wallpaper</p> <p>There are two attempts made to set the wallpaper two using different commands and NEITHER work when in the script. There is a print statement (2nd line from the bottom) that spits out the correct terminal command because I can C&amp;P the print result and it works fine, it just doesn't work when it's executed in the script.</p> <pre><code>#!/usr/bin/env python import urllib2 import os from gi.repository import Gio response = urllib2.urlopen("http://wallbase.cc/random/12/eqeq/1366x768/0.000/100/32") page_source = response.read() thlink_pos = page_source.find("ico-X") address_start = (page_source.find("href=\"", thlink_pos) + 6) address_end = page_source.find("\"", address_start + 1) response = urllib2.urlopen(page_source[address_start:address_end]) page_source = response.read() bigwall_pos = page_source.find("bigwall") address_start = (page_source.find("src=\"", bigwall_pos) + 5) address_end = page_source.find("\"", address_start + 1) address = page_source[address_start:address_end] slash_pos = address.rfind("/") + 1 pic_name = address[slash_pos:] bashCommand = "wget " + page_source[address_start:address_end] os.system(bashCommand) print "Does my new image exists?", os.path.exists(os.getcwd() + "/" + pic_name) #attempt 1 settings = Gio.Settings.new("org.gnome.desktop.background") settings.set_string("picture-uri", "file://" + os.getcwd() + "/" + pic_name) settings.apply() #attempt 2 bashCommand = "gsettings set org.gnome.desktop.background picture-uri file://" + os.getcwd() + "/" + pic_name print bashCommand os.system(bashCommand) settings.apply() </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload