Skip to content

Instantly share code, notes, and snippets.

@hfs
Last active October 9, 2015 18:51
Show Gist options
  • Save hfs/2505d3d852ffb5a6161b to your computer and use it in GitHub Desktop.
Save hfs/2505d3d852ffb5a6161b to your computer and use it in GitHub Desktop.
Awesome window manager: Fetch the NASA Image of the Day and set it as background
#!/bin/bash -e
# Grabs the NASA image of the day by RSS feed and updates the gnome
# background. add this to your cron jobs to have this happen daily. this is,
# obviously, a hack, that is likely to break at the slightest change of NASA's
# RSS implementation. yay standards!
#
# Source: https://awesome.naquadah.org/wiki/NASA_IOTD_Wallpaper
FEED='http://www.nasa.gov/rss/lg_image_of_the_day.rss'
rss=$(wget -q -O - "$FEED")
img_url=$(echo $rss | xmlstarlet sel -t -v '(//item)[1]/enclosure/@url')
img_name=$(echo $rss | xmlstarlet sel -t -v '(//item)[1]/title')
mkdir -p $HOME/.wallpaper
# this command will overwrite the image if it already exists
wget -q -O "$HOME/.wallpaper/$img_name" "$img_url"
# Delete all other (older) images
find $HOME/.wallpaper/ -type f -not -name "$img_name" -delete
feh --bg-fill "$HOME/.wallpaper/$img_name"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment