Last active
January 15, 2016 18:02
-
-
Save evanjarrett/b87d77b20d94275288c3 to your computer and use it in GitHub Desktop.
Grabs a random imgur image from /r/earthporn and sets it as the wallpaper
This file contains 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
#!/bin/bash | |
images=$(curl 'https://www.reddit.com/r/earthporn/hot.json' | grep -Po 'http(s?)://(i.)?imgur.com/.*?"' | sed 's/"//g'); | |
count=$(echo $images | tr -cd " " | wc -c) | |
num=$(($RANDOM % $count + 1)) | |
image=$(awk 'BEGIN { FS = " " } { print $'$num' }' <<< $images) | |
if [[ $image != *.jpg ]]; then | |
image=$(sed 's/imgur/i.imgur/g' <<< $image).jpg | |
fi | |
curl $image -o /usr/local/bin/myfile.jpg | |
gsettings set org.cinnamon.desktop.background picture-uri 'file:///usr/local/bin/myfile.jpg' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment