WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Astronomy Picture of the Day  (Read 1966 times)

Offline roberts

  • Administrator
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Astronomy Picture of the Day
« on: November 05, 2011, 08:27:54 AM »
A site that I regually visit is http://apod.nasa.gov
So just for fun I though to make a downloader to save the picture of the day into /opt/backgrounds so that I may use it as my wallpaper.

Code: [Select]
#!/bin/sh
# Download Astronomy Picture of the Day
VIEWER="flpicsee"
URL="http://apod.nasa.gov/apod"
PIC="$(wget -O - $URL/astropix.html 2>/dev/null | grep '<a href="image')"
[ "$?" == 0 ] || exit 1
PIC="${PIC#*\"}" && PIC=${PIC%\">} && EXT="${PIC##*.}"
POD="/opt/backgrounds/astropic.$EXT"
wget -q -O "$POD" $URL/$PIC
[ "$?" == 0 ] || exit 1
[ $(which "$VIEWER") ] && "$VIEWER" "$POD" &

Note that I have set VIEWER to flpicsee change to your preferred image viewer. Note too that I overwrite each day's picture. I don't want to fill up my limited space. So if you really want to keep a picture rename it!
10+ Years Contributing to Linux Open Source Projects.

Offline coreplayer2

  • Hero Member
  • *****
  • Posts: 3020
Re: Astronomy Picture of the Day
« Reply #1 on: November 05, 2011, 02:02:06 PM »
That's way too cool thanks  :)