Skip to content

Instantly share code, notes, and snippets.

@evanjarrett
Last active January 15, 2016 18:02
Show Gist options
  • Save evanjarrett/b87d77b20d94275288c3 to your computer and use it in GitHub Desktop.
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
#!/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