#!/bin/bash # TO DEBUG: set -x env export DISPLAY=:0.0 export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(id -u)/bus" WALLPAPERS_DIR=/home/pi2/Pictures/wallpapers mkdir -p $WALLPAPERS_DIR NASA_APOD_BASE_URL="https://apod.nasa.gov/apod" IMAGE_URL=`curl -s $NASA_APOD_BASE_URL/astropix.html | grep -oh 'href="image/.*"' | grep -oh 'image/.*jpg' | head -1` if [ "$1" == "r" ] || [ -z "$IMAGE_URL" ]; then IMG=$(ls $WALLPAPERS_DIR | sort -R | tail -1) else IMG="image-$(date --iso).jpg" if [ ! -f $WALLPAPERS_DIR/$IMG ]; then curl -s "$NASA_APOD_BASE_URL/$IMAGE_URL" > $WALLPAPERS_DIR/$IMG fi fi # OPTIONS DEPENDING ON ENV # - for cinnamon #gsettings set org.cinnamon.desktop.background picture-uri "file://$WALLPAPERS_DIR/$IMG" # - for gnome #gsettings set org.gnome.desktop.background picture-uri "file://$WALLPAPERS_DIR/$IMG" # - for i3 # feh --bg-fill "$(pwd)/image.jpg" # - for XFCE (modify the displays names, e.g. to view them - run xrandr) for MONITOR in $(xrandr --listmonitors | tail +2 | cut -d' ' -f6); do xfconf-query --channel xfce4-desktop --property "/backdrop/screen0/monitor${MONITOR}/workspace0/last-image" --set "$WALLPAPERS_DIR/$IMG" done