Skip to content

Instantly share code, notes, and snippets.

@fourkbomb
Created January 17, 2015 03:21
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 fourkbomb/bef48465d1d3e26edb0c to your computer and use it in GitHub Desktop.
Save fourkbomb/bef48465d1d3e26edb0c to your computer and use it in GitHub Desktop.
Download random xkcd and use it as screensaver
#!/bin/sh
# this requires jshon, awk and sed
if ip addr | grep wlan0 | grep UP 2>&1 >/dev/null; then
# we have wifi
URL=$(curl http://c.xkcd.com/random/comic/ --dump-header - | grep Location | awk '{print $2}' | sed 's/\r//g')
JSON=`curl "$URL"info.0.json`
wget $(echo $JSON | jshon -e img | sed 's/"//g' | sed 's/\\//g') -O $HOME/.xkcd.png
fi
i3lock -i ~/.xkcd.png -c 000000 -t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment