You are not logged in.

#1 2009-03-26 19:10:26

deicist
Member
Registered: 2009-03-17
Posts: 36

Random Astronomy picture of the day as wallpaper

This is is no way all my own work, I found the script to download today's APOD and show it as the Gnome background and altered it as follows:

a) fix it to work with gif images as well as jpgs.
b) add xfce4 compatibility
c) get a random image instead of todays image

I'm pretty new to bash scripting, so feel free to suggest improvements.

#!/bin/bash
#Filename: apodwallpaper
#Location: ${HOME}/.bin
#Purposes: Downloads NASA Astronomy Picture of the Day and displays it as the
#          GNOME background 
#Author(s): acvwJosh of Ubuntu Forums, modified by Colin Dean <http://cad.cx>
## Modified by deicist of ARCH linux forums:  added xfce4 support, added .gif support, added random support
## requires athena-jot package from AUR


##random stuff goes here
##start date is a cutoff year to get images after.  I use this because most pre-2000 images are too small to make good desktops
STARTDATE="2000";
NOW=$(date +%Y);
randYear=$(jot -r 1 $STARTDATE $NOW);
randMonth=$(jot -r 1 01 12);
randDay=$(jot -r 1 01 28);
getDate=$(date -d $randYear/$randMonth/$randDay +%y%m%d);

#change this if you want the image to be in a different directory
FILENAME=apodwallpaper
APODWALLPAPER=${HOME}/.${FILENAME}


#remove directory if it exists
rm -rf  ${APODWALLPAPER}
mkdir -p ${APODWALLPAPER} && cd ${APODWALLPAPER}

# download image from apod site
wget -A.gif -A.jpg -R.txt -r -l1 --no-parent -nH http://apod.nasa.gov/apod/ap$getDate.html

# move image from obscure folder to main folder, rename image
find ./apod -name "*.gif" -or -name "*.jpg" | while read line ; do
mv "$line" "${FILENAME}.jpg"
done

#######uncomment next 3 lines for gnome
#gconftool-2 -t string -s /desktop/gnome/background/picture_filename "blank.jpg"
#gconftool-2 -t string -s /desktop/gnome/background/picture_filename "${APODWALLPAPER}/${FILENAME}.jpg"
#gconftool-2 -t string -s /desktop/gnome/background/picture_options "zoom"

######uncomment next line for xfce4 -primary display
#xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s ""
#xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s "${APODWALLPAPER}/${FILENAME}.jpg"
#xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-style -s 3

#uncomment next line for xfce4 -secondary display
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor1/image-path -s ""
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor1/image-path -s "${APODWALLPAPER}/${FILENAME}.jpg"
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor1/image-style -s 3

# Uncomment ONE of the following for use with feh (thanks to SkonesMickLoud)
#feh --bg-tile "${APODWALLPAPER}/${FILENAME}.jpg"
#feh --bg-center "${APODWALLPAPER}/${FILENAME}.jpg"
#feh --bg-scale "${APODWALLPAPER}/${FILENAME}.jpg"
#feh --bg-seamless "${APODWALLPAPER}/${FILENAME}.jpg"

#get rid of cruft
rm -rf apod robots.txt

Last edited by deicist (2009-03-26 19:24:53)

Offline

#2 2009-03-26 19:32:47

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: Random Astronomy picture of the day as wallpaper

I'll close this thread, and move the other one here, as that has the discussion in it.

Offline

Board footer

Powered by FluxBB