-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbiotd.py
More file actions
24 lines (18 loc) · 722 Bytes
/
biotd.py
File metadata and controls
24 lines (18 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/python3
# sets "Bing image of the day" as wallpaper in MATE Desktop
import urllib.request
import json
import os
import random
from subprocess import call
with urllib.request.urlopen("http://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1") as URL:
fetched_data = json.loads(URL.read().decode())
image_url = fetched_data['images'][0]['url']
def image_downloader(image_url):
file_name = str(random.randrange(1, 200))
final = 'https://bing.com' + image_url
urllib.request.urlretrieve(final, file_name)
abs_path_to_image = os.path.abspath(file_name)
call(['gsettings', 'set', 'org.mate.background',
'picture-filename', abs_path_to_image])
image_downloader(image_url)