-
Notifications
You must be signed in to change notification settings - Fork 0
/
apod.sh
executable file
·49 lines (31 loc) · 1.05 KB
/
apod.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
# 7/1/2013
# Grabs the latest APOD image and sets it as the wallpaper.
# Should be run hourly/daily with cron
# This is to let it run with cron
#########################################
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/home/christopher/.local/bin:/home/christopher/bin
export DISPLAY=:0.0
########################################
#exec >/dev/null 2>&1
# Run every 24 hours
# Download apod picture (store in ./images) and set as background
DIR=`dirname $0`
wget -P $DIR http://apod.nasa.gov/apod/astropix.html
NAME=`cat $DIR/astropix.html | grep "<IMG SRC=" | cut -d'"' -f2`
rm $DIR/astropix.html
# 0 found, 1 not.
# exits if there is no jpg
grep -q .jpg <(echo $NAME)
if [ $? -ne 0 ]
then
exit
fi
NAME="http://apod.nasa.gov/apod/"$NAME
wget -nc -P $DIR/images/ $NAME
if [ $? -eq 0 ]
then
NAME=`echo $NAME | cut -d'/' -f7`
gsettings set org.gnome.desktop.background picture-uri file:///home/christopher/Programming/apod/images/$NAME
gsettings set org.gnome.desktop.background picture-options "stretched"
fi