diff options
| author | Ahmed Abdelhalim <[email protected]> | 2026-03-15 13:04:51 +0100 |
|---|---|---|
| committer | Ahmed Abdelhalim <[email protected]> | 2026-03-15 13:19:50 +0100 |
| commit | 111a7396c8a2554f799032edc71fe1d83a8acf2b (patch) | |
| tree | aab7d08806f8205acdb0dd1b758b44a92b67f9f3 /roles/hyprtheme/files/scripts/wallpaper.sh | |
| parent | 0be05816e70bc0cc3ab6bf812fbf5515eddd6b8e (diff) | |
Refactor theme/wallpaper scripts
Diffstat (limited to 'roles/hyprtheme/files/scripts/wallpaper.sh')
| -rwxr-xr-x | roles/hyprtheme/files/scripts/wallpaper.sh | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/roles/hyprtheme/files/scripts/wallpaper.sh b/roles/hyprtheme/files/scripts/wallpaper.sh new file mode 100755 index 00000000..35654b94 --- /dev/null +++ b/roles/hyprtheme/files/scripts/wallpaper.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +show_wallpapers() { + local wallpapers_path="$HOME/.config/hyprtheme/current/wallpapers" + local wallpapers=$(ls -1p "$wallpapers_path" 2>/dev/null) + + if [[ -z $wallpapers ]]; then + notify-send -e \ + -h string:x-canonical-private-synchronous:wallpapers \ + -u normal \ + "Wallpapers" \ + "No wallpapers found for current theme" + pkill -x swaybg + setsid uwsm-app -- swaybg --color '#000000' >/dev/null 2>&1 & + exit 0 + fi + + local selected_wallpaper=$(printf "$wallpapers" | tofi \ + --prompt-text "Select: " \ + --placeholder-text "Wallpaper" + ) + if [[ -n $selected_wallpaper ]]; then + select_wallpaper "$wallpapers_path/$selected_wallpaper" + fi +} + +select_wallpaper() { + local selected_wallpaper="$1" + if [[ ! -f "$selected_wallpaper" ]]; then + notify-send -e \ + -h string:x-canonical-private-synchronous:wallpapers \ + -u critical \ + "Wallpapers" \ + "Wallpaper '$selected_wallpaper' doesn't exist" + pkill -x swaybg + setsid uwsm-app -- swaybg --color '#000000' >/dev/null 2>&1 & + exit 0 + fi + + pkill -x swaybg + setsid uwsm-app -- swaybg -i "$selected_wallpaper" -m fill >/dev/null 2>&1 & +} + +if [[ -z "$1" ]]; then + show_wallpapers +else + select_wallpaper "$1" +fi |
