]> Freerunner's - dotfiles.git/commitdiff
bin: refine rndwallpaper script
authorAndre Ramnitz <tux.rising@gmail.com>
Fri, 15 Dec 2023 14:53:16 +0000 (15:53 +0100)
committerAndre Ramnitz <tux.rising@gmail.com>
Sun, 18 Aug 2024 16:18:52 +0000 (18:18 +0200)
bin/.local/bin/rndwallpaper

index ece08e9705dea02fc7ecbf1570ff23b1de3d9f6b..5732edb15bc30e41f43dd8fcf1b1e4a4e12c757f 100755 (executable)
@@ -3,5 +3,18 @@
 WALLDIR="$HOME/Bilder/Wallpapers"
 
 # set random wallpaper
-echo "$WALLDIR"/"$(find "$WALLDIR" -type f \( -iname \*jpg -o -iname \*jpeg -o -iname \*png -o -iname \*webp \) -printf '"%f"\n' | sort -R | tail -n1)"
+case "$1" in
+    dblquote)
+        find "$WALLDIR" -type f \( -iname \*jpg -o -iname \*jpeg -o -iname \*png -o -iname \*webp \) | sort -R | tail -n1 | sed 's/^/"/;s/$/"/'
+        ;;
+    quote)
+        find "$WALLDIR" -type f \( -iname \*jpg -o -iname \*jpeg -o -iname \*png -o -iname \*webp \) | sort -R | tail -n1 | sed "s/^/'/;s/$/'/"
+        ;;
+    swww)
+        swww img "$(find "$WALLDIR" -type f \( -iname \*jpg -o -iname \*jpeg -o -iname \*png -o -iname \*webp \) | sort -R | tail -n1)"
+        ;;
+    *)
+        find "$WALLDIR" -type f \( -iname \*jpg -o -iname \*jpeg -o -iname \*png -o -iname \*webp \) | sort -R | tail -n1
+        ;;
+esac