edited wallpaper-niri
This commit is contained in:
parent
5e0aef0275
commit
f05962b900
3 changed files with 101 additions and 30 deletions
|
|
@ -1,2 +1,2 @@
|
||||||
# coding
|
# coding
|
||||||
|
just some nice little coding projects, mostly bash (and vibecoded lol)
|
||||||
|
|
|
||||||
55
testing-wallpaper
Executable file
55
testing-wallpaper
Executable file
|
|
@ -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" <<EOF
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
pgrep -x awww-daemon >/dev/null || awww-daemon &
|
||||||
|
sleep 0.5
|
||||||
|
awww img "$full_path" --transition-type simple
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chmod +x "$persist"
|
||||||
|
|
||||||
|
notify-send "Wallpaper" "$chosen" --urgency=low
|
||||||
|
|
@ -1,39 +1,55 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
# wallpaper-picker.sh (Niri version)
|
set -euo pipefail
|
||||||
|
|
||||||
WALLPAPER_DIR="$HOME/Pictures/wallpaper"
|
WALLPAPER_DIR="${HOME}/Pictures/wallpaper"
|
||||||
EXTENSIONS="jpg|jpeg|png|gif|webp|bmp|tiff|tga|svg|avif"
|
EXTENSIONS="jpg|jpeg|png|gif|webp|bmp|tiff|tga|svg|avif"
|
||||||
|
|
||||||
declare -A wall_map
|
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"
|
wall_map["$name"]="$path"
|
||||||
done < <(find "$WALLPAPER_DIR" -maxdepth 1 -type f \
|
done < <(
|
||||||
-regextype posix-extended -iregex ".*\.($EXTENSIONS)" | sort)
|
find "$WALLPAPER_DIR" -maxdepth 1 -type f \
|
||||||
|
-regextype posix-extended \
|
||||||
chosen=$(printf '%s\n' "${!wall_map[@]}" | sort | \
|
-iregex ".*\.(${EXTENSIONS})" \
|
||||||
wofi \
|
-print0 | sort -z
|
||||||
--dmenu \
|
|
||||||
--prompt " Wallpaper" \
|
|
||||||
--insensitive \
|
|
||||||
--no-actions \
|
|
||||||
--width 500 \
|
|
||||||
--height 400 \
|
|
||||||
)
|
)
|
||||||
|
|
||||||
[[ -z "$chosen" ]] && exit 0
|
chosen="$(
|
||||||
|
for name in "${!wall_map[@]}"; do
|
||||||
full_path="${wall_map[$chosen]}"
|
printf '%s\0icon\x1fthumbnail://%s\n' "$name" "${wall_map[$name]}"
|
||||||
[[ ! -f "$full_path" ]] && {
|
done | sort | rofi \
|
||||||
notify-send "wallpaper-picker" "Not found: $full_path" --urgency=critical
|
-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
|
exit 1
|
||||||
}
|
fi
|
||||||
|
|
||||||
awww img "$full_path" --transition-type grow --transition-step 90
|
awww img "$full_path" --transition-type grow --transition-step 90
|
||||||
|
|
||||||
persist="$HOME/.config/niri/wallpaper-restore.sh"
|
persist="$HOME/.config/niri/wallpaper-restore.sh"
|
||||||
mkdir -p "$(dirname "$persist")"
|
mkdir -p "$(dirname "$persist")"
|
||||||
printf '#!/bin/bash\nawww-daemon &\nsleep 0.5\nawww img "%s" --transition-type simple\n' "$full_path" > "$persist"
|
|
||||||
|
cat > "$persist" <<EOF
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
pgrep -x awww-daemon >/dev/null || awww-daemon &
|
||||||
|
sleep 0.5
|
||||||
|
awww img "$full_path" --transition-type simple
|
||||||
|
EOF
|
||||||
|
|
||||||
chmod +x "$persist"
|
chmod +x "$persist"
|
||||||
|
|
||||||
notify-send "Wallpaper" "$chosen" --urgency=low
|
notify-send "Wallpaper" "$chosen" --urgency=low
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue