From f05962b900042921ccdddbed9d0809ea6b96a33f Mon Sep 17 00:00:00 2001 From: denode Date: Thu, 2 Apr 2026 08:29:20 +0200 Subject: [PATCH] edited wallpaper-niri --- README.md | 2 +- testing-wallpaper | 55 +++++++++++++++++++++++++++++++++++ wallpaper-niri | 74 ++++++++++++++++++++++++++++------------------- 3 files changed, 101 insertions(+), 30 deletions(-) create mode 100755 testing-wallpaper diff --git a/README.md b/README.md index 4d63fd4..7d5367c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ # coding - +just some nice little coding projects, mostly bash (and vibecoded lol) diff --git a/testing-wallpaper b/testing-wallpaper new file mode 100755 index 0000000..1e9c0f3 --- /dev/null +++ b/testing-wallpaper @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +set -euo pipefail + +WALLPAPER_DIR="${HOME}/Pictures/wallpaper" +EXTENSIONS="jpg|jpeg|png|gif|webp|bmp|tiff|tga|svg|avif" + +declare -A wall_map + +while IFS= read -r -d '' path; do + name="$(basename "$path")" + wall_map["$name"]="$path" +done < <( + find "$WALLPAPER_DIR" -maxdepth 1 -type f \ + -regextype posix-extended \ + -iregex ".*\.(${EXTENSIONS})" \ + -print0 | sort -z +) + +chosen="$( + for name in "${!wall_map[@]}"; do + printf '%s\0icon\x1fthumbnail://%s\n' "$name" "${wall_map[$name]}" + done | sort | rofi \ + -dmenu \ + -show-icons \ + -i \ + -p "Wallpaper" \ + -theme "$HOME/.config/rofi/wallpaper.rasi" \ + -kb-accept-entry "Return,KP_Enter" \ + -kb-element-next "Tab" \ + -kb-element-prev "ISO_Left_Tab" +)" + +[[ -z "${chosen:-}" ]] && exit 0 + +full_path="${wall_map[$chosen]:-}" +if [[ -z "${full_path}" || ! -f "${full_path}" ]]; then + notify-send "wallpaper-picker" "Not found: $chosen" --urgency=critical + exit 1 +fi + +awww img "$full_path" --transition-type grow --transition-step 90 + +persist="$HOME/.config/niri/wallpaper-restore.sh" +mkdir -p "$(dirname "$persist")" + +cat > "$persist" </dev/null || awww-daemon & +sleep 0.5 +awww img "$full_path" --transition-type simple +EOF + +chmod +x "$persist" + +notify-send "Wallpaper" "$chosen" --urgency=low diff --git a/wallpaper-niri b/wallpaper-niri index 41bf7d4..462f127 100755 --- a/wallpaper-niri +++ b/wallpaper-niri @@ -1,39 +1,55 @@ -#!/bin/bash -# wallpaper-picker.sh (Niri version) - -WALLPAPER_DIR="$HOME/Pictures/wallpaper" +#!/usr/bin/env bash +set -euo pipefail + +WALLPAPER_DIR="${HOME}/Pictures/wallpaper" EXTENSIONS="jpg|jpeg|png|gif|webp|bmp|tiff|tga|svg|avif" - + declare -A wall_map -while IFS= read -r path; do - name=$(basename "$path") + +while IFS= read -r -d '' path; do + name="$(basename "$path")" wall_map["$name"]="$path" -done < <(find "$WALLPAPER_DIR" -maxdepth 1 -type f \ - -regextype posix-extended -iregex ".*\.($EXTENSIONS)" | sort) - -chosen=$(printf '%s\n' "${!wall_map[@]}" | sort | \ - wofi \ - --dmenu \ - --prompt " Wallpaper" \ - --insensitive \ - --no-actions \ - --width 500 \ - --height 400 \ +done < <( + find "$WALLPAPER_DIR" -maxdepth 1 -type f \ + -regextype posix-extended \ + -iregex ".*\.(${EXTENSIONS})" \ + -print0 | sort -z ) - -[[ -z "$chosen" ]] && exit 0 - -full_path="${wall_map[$chosen]}" -[[ ! -f "$full_path" ]] && { - notify-send "wallpaper-picker" "Not found: $full_path" --urgency=critical + +chosen="$( + for name in "${!wall_map[@]}"; do + printf '%s\0icon\x1fthumbnail://%s\n' "$name" "${wall_map[$name]}" + done | sort | rofi \ + -dmenu \ + -show-icons \ + -i \ + -p "wallpaper" \ + -theme "$HOME/.config/rofi/wallpaper.rasi" \ + -kb-accept-entry "Return,KP_Enter" \ + -kb-element-next "Tab" \ + -kb-element-prev "ISO_Left_Tab" +)" + +[[ -z "${chosen:-}" ]] && exit 0 + +full_path="${wall_map[$chosen]:-}" +if [[ -z "${full_path}" || ! -f "${full_path}" ]]; then + notify-send "wallpaper-picker" "Not found: $chosen" --urgency=critical exit 1 -} - +fi + awww img "$full_path" --transition-type grow --transition-step 90 - + persist="$HOME/.config/niri/wallpaper-restore.sh" mkdir -p "$(dirname "$persist")" -printf '#!/bin/bash\nawww-daemon &\nsleep 0.5\nawww img "%s" --transition-type simple\n' "$full_path" > "$persist" + +cat > "$persist" </dev/null || awww-daemon & +sleep 0.5 +awww img "$full_path" --transition-type simple +EOF + chmod +x "$persist" - + notify-send "Wallpaper" "$chosen" --urgency=low