Skip to content

Instantly share code, notes, and snippets.

@janoamaral
Created June 21, 2017 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janoamaral/4c9191b25a83f6a243e30f09567de9ec to your computer and use it in GitHub Desktop.
Save janoamaral/4c9191b25a83f6a243e30f09567de9ec to your computer and use it in GitHub Desktop.
Change the wallpaper every hour using Unsplash.com API.
#!/bin/bash
# TODO:
# Add switch to change the wait period
# Add switch to change the image geometry
while [ : ]
do
wget --quiet -O ~/dotfiles/bg.jpg `curl -s "https://api.unsplash.com/photos/random/?client_id=YOUR_UNSPLASH_CLIENTE_ID" | grep -E "full\":\"https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)" -o | grep -E "https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)" -o`
# Resize the image to optimize
convert ~/bg.jpg -resize 1280 ~/bg.jpg
# Set the background
feh --bg-fill ~/bg.jpg
# Wait 1 hour
sleep 1h
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment