#! /usr/bin/env sh if [ -f "$HOME/.local/etc/x/chwp" ] then . "$HOME/.local/etc/x/chwp" fi directory=${CHWP_BASEDIR:-$HOME/pictures/wallpapers} size=${CHWP_SIZE:-1920x1080} timeout=${1:-0} walldir=$directory/$size if [ ! -d "$walldir" ] then printf "%s\n" "No such directory: $walldir" >&2 fi # If no timeout was set, just change it once if [ "$timeout" -eq 0 ] then find "${walldir}" -type f -print0 | shuf -n1 -z | xargs -0 feh --bg-fill exit 0 fi # Otherwise, change it every so often while : do find "${walldir}" -type f -print0 | shuf -n1 -z | xargs -0 feh --bg-fill sleep "${timeout}" done