Last active
August 20, 2021 10:55
-
-
Save tudoanh/045674f5502b37268fcc45162d6c9830 to your computer and use it in GitHub Desktop.
Random wallpaper on Ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import random | |
import requests | |
import subprocess | |
topic = random.choice( | |
["meal", "food", "beverage", "wine", "bread", "restaurant", "work"] | |
) | |
url = f"https://source.unsplash.com/1920x1080/?{topic}" | |
print(url) | |
subprocess.call(["wget", "-nv", "-O", "/home/james/Downloads/wallpaper.jpg", url]) | |
subprocess.call( | |
[ | |
"gsettings", | |
"set", | |
"org.gnome.desktop.background", | |
"picture-uri", | |
f"file:///home/james/Downloads/wallpaper.jpg", | |
] | |
) | |
print(f"Set wallpaper {topic} succeed") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
chmod a+x unsplash.py
Then update crontab
*/30 * * * * /home/james/unsplash.py