Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# apod-desktop
Script to set your Linux desktop wallpaper to the Astronomy Picture of the Day.
Script to set your Linux or Windows 10 desktop wallpaper to the Astronomy Picture of the Day.

## Usage
Invoke the script on login using a method appropriate to your desktop manager
```
Usage: apod gnome1|gnome22|gnome24|gnome3|kde|fvwm|fvwm-xv|xfce|xfce4|hsetroot
Usage: apod gnome1|gnome22|gnome24|gnome3|kde|fvwm|fvwm-xv|xfce|xfce4|hsetroot|windows
```

## How it works
Expand All @@ -19,6 +19,7 @@ The current supported list is as follows:
* XFCE
* Enlightenment
* Generic X11 using hsetroot
* Windows 10

## Temporary transition image
I found that for some desktops, resetting the wallpaper to a new file with the same name did not always refresh. For those desktop managers, I switch to a default temporary image first, then back to the new APOD image. I have provided a sample image with this repository which is a copy of the classic RCA "Indian Head" TV test pattern [Source](https://en.wikipedia.org/wiki/File:RCA_Indian_Head_test_pattern.JPG). This is of course highly insensitive, so feel free to change it to something else you prefer.
Expand Down
18 changes: 12 additions & 6 deletions apod
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@

###########################################
# CHANGE THE FOLLOWING TO SUIT YOUR NEEDS
imgdir=$HOME/pics
imgdir=$HOME/Pictures
tmpimg=$imgdir/rca_indian_head_test_pattern.jpg

# base URL for the APOD website
baseurl=http://apod.nasa.gov/apod/
baseurl=https://apod.nasa.gov/apod/
# base URL plus name of the page where the current picture can be found
sourceurl=${baseurl}astropix.html
tmpfile=/tmp/astropix.html
imgfile=$imgdir/apod.jpg

# attempt to retrieve the astropix page
echo getting page ${sourceurl}
wget ${sourceurl} -T 10 -q -O $tmpfile
curl ${sourceurl} -s -o "$tmpfile"

if [ $? -ne 0 ]; then
echo "Unable to retrieve page";
exit 1;
else
# extract the image url from the astropix page
echo getting image url
imgurl=`cat $tmpfile | grep -i "img src" | sed -e 's/.*<img src="\(.*\)".*/\1/i'`
imgurl=`cat $tmpfile | grep -i "a.*image/" | sed -e 's/.*<a href="\(.*\)".*/\1/i'`

# get that image file
echo getting image ${baseurl}${imgurl}
wget ${baseurl}${imgurl} -T 10 -q -O $imgfile
curl ${baseurl}${imgurl} -s -o "$imgfile"
if [ $? -ne 0 ]; then
echo "Unable to retrieve image"
exit 2
Expand Down Expand Up @@ -106,8 +106,14 @@ else
"hsetroot")
hsetroot -fill "$imgfile"
;;
"windows")
winimg=`echo $imgfile | sed -e 's/\/c/C:/i'`
reg add "HKEY_CURRENT_USER\Control Panel\Desktop" //v Wallpaper //t REG_SZ //d "$winimg" //f
sleep 5
echo "RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters, 1 True"| "C:/Windows/System32/WindowsPowerShell/v1.0/powershell"
;;
*)
echo "Usage: apod gnome1|gnome22|gnome24|gnome3|kde|fvwm|fvwm-xv|xfce|xfce4|hsetroot"
echo "Usage: apod gnome1|gnome22|gnome24|gnome3|kde|fvwm|fvwm-xv|xfce|xfce4|hsetroot|windows"
;;
esac
fi
Expand Down