aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/chwp
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2019-10-02 16:41:02 +0200
committerPatrick Spek <p.spek@tyil.nl>2019-10-02 16:41:02 +0200
commit035bb70ce47ce7e5a643b80e130985b6d711e99f (patch)
tree496b9f03a2e9986b6e1fc25311490c90e0042ae4 /.local/bin/chwp
parentd62f1d1673fc0a319ea4581dee0f6085b1f70005 (diff)
Add a number of shell utilities
Diffstat (limited to '.local/bin/chwp')
-rwxr-xr-x.local/bin/chwp30
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