Last active
December 28, 2015 22:49
-
-
Save mx-moth/7574249 to your computer and use it in GitHub Desktop.
Set your desktop background to the latest image from NASAs Solar Dynamics Observatory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The images from the SDO are updated every 15 minutes, so this script should only be run every 15 minutes. | |
DISPLAY=:0 | |
4-59/15 * * * * $HOME/sdo-update --silent --type "0171" --screen "screen0/monitor0" | |
5-59/15 * * * * $HOME/sdo-update --silent --type "0193" --screen "screen0/monitor1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
opts=$( getopt -o 'stxo' -l 'type:,size:,out:,screen:,silent' -n "${0}" -- "$@" ) | |
if [ $? != 0 ] ; then exit 1 ; fi | |
eval set -- "$opts" | |
# Check out http://sdo.gsfc.nasa.gov/data/ for the different types and sizes. | |
SDO_SIZE="2048" | |
SDO_TYPE="0171" | |
# Images will be saved here | |
SDO_DIR="$HOME/Pictures/SDO" | |
# Select the screen/monitor you want to update | |
XCONF_SCREEN="screen0/monitor0" | |
LOG_LEVEL=1 | |
while true ; do case "$1" in | |
-s|--silent) LOG_LEVEL=$(( $LOG_LEVEL - 1 )) ; shift ;; | |
-t|--type) SDO_TYPE="$2" ; shift 2 ;; | |
-x|--size) SDO_SIZE="$2" ; shift 2 ;; | |
-o|--out) SDO_DIR="$2" ; shift 2 ;; | |
--screen) XCONF_SCREEN="$2" ; shift 2 ;; | |
--) shift ; break ;; | |
*) echo "Internal error! $1" >&2 ; exit 1 ;; | |
esac ; done | |
log() { | |
level="$1" | |
shift | |
if [ "$level" -le "$LOG_LEVEL" ] ; then | |
echo "$@" | |
fi | |
} | |
if [ "$LOG_LEVEL" -eq 0 ] ; then | |
CURL="curl -s" | |
else | |
CURL="curl -#" | |
fi | |
CURL="${CURL} -C -" | |
IMAGE_SRC="http://sdo.gsfc.nasa.gov/assets/img/latest/latest_${SDO_SIZE}_${SDO_TYPE}.jpg" | |
IMAGE_DST="${SDO_DIR}/$( date '+%Y/%m/%d/%H%M' )_${SDO_SIZE}_${SDO_TYPE}.jpg" | |
# Download the image | |
log 1 "${IMAGE_DST}" | |
mkdir -p "$( dirname "$IMAGE_DST" )" | |
$CURL -o "${IMAGE_DST}" -- "${IMAGE_SRC}" | |
# Set it as the desktop. If you use something other than xfce, you will need to change this. | |
xfconf-query \ | |
--channel xfce4-desktop \ | |
--property "/backdrop/${XCONF_SCREEN}/image-path" \ | |
--set "${IMAGE_DST}" |
eval-apply
commented
Nov 21, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment