diff options
Diffstat (limited to '.local/bin/chwp')
-rwxr-xr-x | .local/bin/chwp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/.local/bin/chwp b/.local/bin/chwp new file mode 100755 index 0000000..071bf3a --- /dev/null +++ b/.local/bin/chwp @@ -0,0 +1,30 @@ +#! /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 |