Skip to content

Instantly share code, notes, and snippets.

@sjsakib
Last active February 6, 2020 21:59
Show Gist options
  • Save sjsakib/e988bb1eafc4697c753928ab9dff9d00 to your computer and use it in GitHub Desktop.
Save sjsakib/e988bb1eafc4697c753928ab9dff9d00 to your computer and use it in GitHub Desktop.
This script gets a random featured image from unsplash.com and sets it as your desktop background. Works on `gsettings` supported linux distros. Tested on Ubuntu 19.10 (Gnome). Requires the `requests` module to be installed. It takes some time to download the photo. So, wait patiently after executing the script. You can use `anacrontab` to run i…

This script gets a random featured image from unsplash.com and sets it as your desktop background. Works on gsettings supported linux distros. Tested on Ubuntu 19.10 (Gnome). Requires the requests module to be installed.

It takes some time to download the photo. So, wait patiently after executing the script.

You can use anacrontab to run it daily or weekly. See http://bit.ly/371ybhq

#!/usr/bin/env python3
"""
This script gets a random featured image from unsplash.com and sets it as your desktop background. Works on `gsettings` supported linux distros. Tested on Ubuntu 19.10 (Gnome). Requires the `requests` module to be installed.
It takes some time to download the photo. So, wait patiently after executing the script.
You can use `anacrontab` to run it daily or weekly. See http://bit.ly/371ybhq
"""
import requests
from os import system
# Create an app here: https://unsplash.com/oauth/applications
# and collect your client_id (Access Key)
client_id = '***'
def unsplash(path, **params):
return requests.get('https://api.unsplash.com' + path, params={'client_id': client_id, **params})
res = unsplash('/photos/random', featured=True, orientation='landscape')
url = res.json()['urls']['regular']
system(f'gsettings set org.gnome.desktop.background picture-uri {url}')
@raikusy
Copy link

raikusy commented Feb 6, 2020

Cool 💯

@jaamaalxyz
Copy link

good job vai 💯 👍

@thedeadfish59
Copy link

brilliant!

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