Refactor wallpaper_shuffle
authorSiraaj Khandkar <siraaj@khandkar.net>
Mon, 17 Jan 2022 15:31:07 +0000 (10:31 -0500)
committerSiraaj Khandkar <siraaj@khandkar.net>
Mon, 17 Jan 2022 15:31:07 +0000 (10:31 -0500)
home/bin/randline [new file with mode: 0755]
home/bin/wallpaper_shuffle
home/lib/login_variables.sh

diff --git a/home/bin/randline b/home/bin/randline
new file mode 100755 (executable)
index 0000000..ccd294f
--- /dev/null
@@ -0,0 +1,7 @@
+#! /usr/bin/awk -f
+
+BEGIN {srand()}
+
+{lines[n++] = $0}
+
+END {print lines[int(n * rand())]}
index 1fd851a..0c05d15 100755 (executable)
@@ -2,20 +2,4 @@
 
 set -e
 
-path=$(
-    find \
-        $@ \
-        -type f \
-    | awk '
-        {
-            paths[i++] = $0
-        }
-
-        END {
-            srand()
-            j = int(i * rand())
-            print paths[j]
-        }'
-)
-printf "$path\n" >&2
-feh --bg-scale "$path"
+feh --bg-scale "$(find "$DIR_WALLPAPERS" -type f | randline)"
index 1fd515b..fe0d1cf 100644 (file)
@@ -11,6 +11,7 @@ export DIR_NOTES="$HOME/doc/notes"
 export DIR_LOG="$HOME/var/log"
 export DIR_LOG_MPD="$DIR_LOG/mpd"
 export DIR_NQ="$HOME/var/run/nq"
+export DIR_WALLPAPERS="$HOME/arc/img/Wallpapers"
 
 # ensure all DIRs exist:
 env | grep ^DIR_ | awk -F= '{print $2}' | xargs -I% mkdir -p '%'
This page took 0.02947 seconds and 4 git commands to generate.