aboutsummaryrefslogtreecommitdiff
path: root/wallpaper-picker.sh
diff options
context:
space:
mode:
authorMikkel Thestrup <mikkel@mithe.dk>2026-01-28 22:41:04 +0100
committerMikkel Thestrup <mikkel@mithe.dk>2026-01-28 22:41:04 +0100
commitc7a90c9c929e4715532c8857406e17bd46ba2f59 (patch)
tree90558f8354732b499eadcbcd0130bd1e11ee3220 /wallpaper-picker.sh
parent83107c60c0a1135e4548d588eef7d94b2adaa1af (diff)
downloadscripts-c7a90c9c929e4715532c8857406e17bd46ba2f59.tar.gz
scripts-c7a90c9c929e4715532c8857406e17bd46ba2f59.zip
Improving wallpaper picker
Diffstat (limited to 'wallpaper-picker.sh')
-rwxr-xr-xwallpaper-picker.sh27
1 files changed, 11 insertions, 16 deletions
diff --git a/wallpaper-picker.sh b/wallpaper-picker.sh
index 7b26563..47645a2 100755
--- a/wallpaper-picker.sh
+++ b/wallpaper-picker.sh
@@ -1,30 +1,25 @@
#!/bin/sh
-# Program for picking wallpaper using Dmenu.
+# Pick a wallpaper using dmenu
-FOLDER="$HOME/pictures/wallpaper"
+WALLPAPER_DIR="$HOME/pictures/wallpaper"
-menu() {
- CHOICE=$(ls "$FOLDER" | dmenu -l 15 -i -p "Wallpaper: ")
+pick_wallpaper() {
+ choice=$(find "$WALLPAPER_DIR" -maxdepth 1 -type f -printf '%f\n' 2>/dev/null \
+ | dmenu -i -l 15 -p "Wallpaper:")
- case "$CHOICE" in
- *.*)
- wallpaper "$FOLDER/$CHOICE"
- ;;
- *)
- exit 0
- ;;
-
- esac
+ [ -n "$choice" ] || exit 0
+
+ wallpaper "$WALLPAPER_DIR/$choice"
}
-case "$#" in
+case $# in
0)
- menu
+ pick_wallpaper
;;
1)
wallpaper "$1"
;;
*)
- exit 0
+ exit 1
;;
esac