From 035bb70ce47ce7e5a643b80e130985b6d711e99f Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Wed, 2 Oct 2019 16:41:02 +0200 Subject: Add a number of shell utilities --- .local/bin/chwp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 .local/bin/chwp (limited to '.local/bin/chwp') 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 -- cgit v1.1