Skip to content

Instantly share code, notes, and snippets.

@tudoanh
Last active August 20, 2021 10:55
Show Gist options
  • Save tudoanh/045674f5502b37268fcc45162d6c9830 to your computer and use it in GitHub Desktop.
Save tudoanh/045674f5502b37268fcc45162d6c9830 to your computer and use it in GitHub Desktop.
Random wallpaper on Ubuntu
#!/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")
@tudoanh
Copy link
Author

tudoanh commented Aug 20, 2021

chmod a+x unsplash.py

Then update crontab

*/30 * * * * /home/james/unsplash.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment