diff options
| author | BardofSprites <[email protected]> | 2026-01-06 23:28:55 -0500 |
|---|---|---|
| committer | BardofSprites <[email protected]> | 2026-01-06 23:28:55 -0500 |
| commit | f8d58bfed5bed488e6a5c809a55216a0650deac9 (patch) | |
| tree | 4e7640a95a188b00af9b17e88c7a243a8e476e80 /bin | |
| parent | 6339e0c6528d77c52a5b27d07264e4b46ac16147 (diff) | |
add cmd line options for wallpaper in $1
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/.local/bin/scripts/wallpaper.sh | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/bin/.local/bin/scripts/wallpaper.sh b/bin/.local/bin/scripts/wallpaper.sh index 6dc0c03..052b8c8 100755 --- a/bin/.local/bin/scripts/wallpaper.sh +++ b/bin/.local/bin/scripts/wallpaper.sh @@ -1,17 +1,32 @@ #!/usr/bin/env bash +# Exit on error +set -e # Path to the directory containing your wallpapers -WALLPAPER_DIRS="$HOME/Pictures/wallpaper/\n$HOME/Pictures/other-wallpaper/" +WALLPAPER_DIRS="$HOME/Pictures/wallpaper +$HOME/Pictures/other-wallpaper" -WALLPAPER_DIR=$(echo -e "$WALLPAPER_DIRS" | dmenu -p "Select directory: ") +# If image is passed as argument, skip selection +if [ -n "$1" ]; then + selected_wallpaper="$1" -if [ -z "$WALLPAPER_DIR" ]; then - exit 1 -fi + # Optional: expand ~ and get absolute path + selected_wallpaper="$(realpath "$selected_wallpaper")" + + if [ ! -f "$selected_wallpaper" ]; then + echo "Error: File does not exist: $selected_wallpaper" + exit 1 + fi +else + WALLPAPER_DIR=$(printf "%s\n" "$WALLPAPER_DIRS" | dmenu -p "Select directory:") -# Use nsxiv to mark an image -selected_wallpaper=$(nsxiv -t -r -o $WALLPAPER_DIR) + [ -z "$WALLPAPER_DIR" ] && exit 1 + + selected_wallpaper=$(nsxiv -t -r -o "$WALLPAPER_DIR") + + [ -z "$selected_wallpaper" ] && exit 1 +fi # Options for display modes OPTIONS="Tiled\nZoom Filled\nCentered\nMax" |
