From f8d58bfed5bed488e6a5c809a55216a0650deac9 Mon Sep 17 00:00:00 2001 From: BardofSprites <89086143+BardofSprites@users.noreply.github.com> Date: Tue, 6 Jan 2026 23:28:55 -0500 Subject: add cmd line options for wallpaper in $1 --- bin/.local/bin/scripts/wallpaper.sh | 29 ++++++++++++++++++++++------- 1 file 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" -- cgit v1.2.3