summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmed Abdelhalim <[email protected]>2026-03-15 13:04:51 +0100
committerAhmed Abdelhalim <[email protected]>2026-03-15 13:19:50 +0100
commit111a7396c8a2554f799032edc71fe1d83a8acf2b (patch)
treeaab7d08806f8205acdb0dd1b758b44a92b67f9f3
parent0be05816e70bc0cc3ab6bf812fbf5515eddd6b8e (diff)
Refactor theme/wallpaper scripts
-rw-r--r--roles/hyprtheme/files/scripts/theme-bg-next49
-rw-r--r--roles/hyprtheme/files/scripts/theme-set47
-rwxr-xr-xroles/hyprtheme/files/scripts/theme.sh67
-rwxr-xr-xroles/hyprtheme/files/scripts/wallpaper.sh48
-rw-r--r--roles/hyprtheme/files/themes/catppuccin/wallpapers/a_flower_on_a_dark_background.png (renamed from roles/hyprtheme/files/themes/catppuccin/backgrounds/a_flower_on_a_dark_background.png)bin360648 -> 360648 bytes
-rw-r--r--roles/hyprtheme/files/themes/catppuccin/wallpapers/leef_dark_purple_minimalist.png (renamed from roles/hyprtheme/files/themes/catppuccin/backgrounds/leef_dark_purple_minimalist.png)bin950831 -> 950831 bytes
-rw-r--r--roles/hyprtheme/files/themes/everforest/wallpapers/1-a_pile_of_cut_logs.jpg (renamed from roles/hyprtheme/files/themes/everforest/backgrounds/1-a_pile_of_cut_logs.jpg)bin3687179 -> 3687179 bytes
-rw-r--r--roles/hyprtheme/files/themes/everforest/wallpapers/2-everforest.jpg (renamed from roles/hyprtheme/files/themes/everforest/backgrounds/2-everforest.jpg)bin322827 -> 322827 bytes
-rw-r--r--roles/hyprtheme/files/themes/gruvbox/wallpapers/2-gruvbox.jpg (renamed from roles/hyprtheme/files/themes/gruvbox/backgrounds/2-gruvbox.jpg)bin443959 -> 443959 bytes
-rw-r--r--roles/hyprtheme/files/themes/gruvbox/wallpapers/a_road_surrounded_by_trees.jpg (renamed from roles/hyprtheme/files/themes/gruvbox/backgrounds/a_road_surrounded_by_trees.jpg)bin1290664 -> 1290664 bytes
-rw-r--r--roles/hyprtheme/files/themes/matte-black/wallpapers/0-ship-at-sea.jpg (renamed from roles/hyprtheme/files/themes/matte-black/backgrounds/0-ship-at-sea.jpg)bin1681677 -> 1681677 bytes
-rw-r--r--roles/hyprtheme/files/themes/matte-black/wallpapers/1-matte-black.jpg (renamed from roles/hyprtheme/files/themes/matte-black/backgrounds/1-matte-black.jpg)bin1033920 -> 1033920 bytes
-rw-r--r--roles/hyprtheme/files/themes/matte-black/wallpapers/2-matte-black-hands.jpg (renamed from roles/hyprtheme/files/themes/matte-black/backgrounds/2-matte-black-hands.jpg)bin482067 -> 482067 bytes
-rw-r--r--roles/hyprtheme/files/themes/osaka-jade/wallpapers/3-osaka-jade-bg.jpg (renamed from roles/hyprtheme/files/themes/osaka-jade/backgrounds/3-osaka-jade-bg.jpg)bin2243941 -> 2243941 bytes
-rw-r--r--roles/hyprtheme/files/themes/ristretto/wallpapers/1-ristretto.jpg (renamed from roles/hyprtheme/files/themes/ristretto/backgrounds/1-ristretto.jpg)bin210019 -> 210019 bytes
-rw-r--r--roles/hyprtheme/files/themes/ristretto/wallpapers/2-ristretto.jpg (renamed from roles/hyprtheme/files/themes/ristretto/backgrounds/2-ristretto.jpg)bin1538954 -> 1538954 bytes
-rw-r--r--roles/hyprtheme/files/themes/ristretto/wallpapers/3-ristretto.jpg (renamed from roles/hyprtheme/files/themes/ristretto/backgrounds/3-ristretto.jpg)bin816682 -> 816682 bytes
-rw-r--r--roles/hyprtheme/files/themes/tokyo-night/wallpapers/1-scenery-pink-lakeside-sunset-lake-landscape-scenic-panorama-7680x3215-144.png (renamed from roles/hyprtheme/files/themes/tokyo-night/backgrounds/1-scenery-pink-lakeside-sunset-lake-landscape-scenic-panorama-7680x3215-144.png)bin2804358 -> 2804358 bytes
-rw-r--r--roles/hyprtheme/tasks/main.yml6
19 files changed, 118 insertions, 99 deletions
diff --git a/roles/hyprtheme/files/scripts/theme-bg-next b/roles/hyprtheme/files/scripts/theme-bg-next
deleted file mode 100644
index e0edb2a3..00000000
--- a/roles/hyprtheme/files/scripts/theme-bg-next
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/bin/bash
-
-# Cycles through the background images available
-
-THEMES_PATH="$HOME/.config/hyprtheme/"
-THEME_BACKGROUNDS_PATH="$THEMES_PATH/current/backgrounds/"
-CURRENT_BACKGROUND_LINK="$THEMES_PATH/current/background"
-
-mapfile -d '' -t BACKGROUNDS < <(find -L "$THEME_BACKGROUNDS_PATH" -maxdepth 1 -type f -print0 2>/dev/null | sort -z)
-TOTAL=${#BACKGROUNDS[@]}
-
-if [[ $TOTAL -eq 0 ]]; then
- notify-send "No background was found for theme" -t 2000
- pkill -x swaybg
- setsid uwsm-app -- swaybg --color '#000000' >/dev/null 2>&1 &
-else
- # Get current background from symlink
- if [[ -L "$CURRENT_BACKGROUND_LINK" ]]; then
- CURRENT_BACKGROUND=$(readlink "$CURRENT_BACKGROUND_LINK")
- else
- # Default to first background if no symlink exists
- CURRENT_BACKGROUND=""
- fi
-
- # Find current background index
- INDEX=-1
- for i in "${!BACKGROUNDS[@]}"; do
- if [[ "${BACKGROUNDS[$i]}" == "$CURRENT_BACKGROUND" ]]; then
- INDEX=$i
- break
- fi
- done
-
- # Get next background (wrap around)
- if [[ $INDEX -eq -1 ]]; then
- # Use the first background when no match was found
- NEW_BACKGROUND="${BACKGROUNDS[0]}"
- else
- NEXT_INDEX=$(((INDEX + 1) % TOTAL))
- NEW_BACKGROUND="${BACKGROUNDS[$NEXT_INDEX]}"
- fi
-
- # Set new background symlink
- ln -nsf "$NEW_BACKGROUND" "$CURRENT_BACKGROUND_LINK"
-
- # Relaunch swaybg
- pkill -x swaybg
- setsid uwsm-app -- swaybg -i "$CURRENT_BACKGROUND_LINK" -m fill >/dev/null 2>&1 &
-fi
diff --git a/roles/hyprtheme/files/scripts/theme-set b/roles/hyprtheme/files/scripts/theme-set
deleted file mode 100644
index d33cd1f9..00000000
--- a/roles/hyprtheme/files/scripts/theme-set
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/bash
-
-# Extracted from omarchy with a little modifications
-if [[ -z $1 ]]; then
- echo "Usage: theme-set <theme-name>"
- exit 1
-fi
-
-THEMES_PATH="$HOME/.config/hyprtheme/themes"
-CURRENT_THEME_PATH="$HOME/.config/hyprtheme/current"
-THEME_NAME=$(echo "$1" | sed -E 's/<[^>]+>//g' | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
-
-if [[ ! -d "$THEMES_PATH/$THEME_NAME" ]]; then
- echo "Theme '$THEME_NAME' does not exist"
- exit 1
-fi
-
-# Get close to as atomic as possible.
-ln -sfn "$THEMES_PATH/$THEME_NAME" "$CURRENT_THEME_PATH.new"
-rm -rf "$CURRENT_THEME_PATH"
-mv "$CURRENT_THEME_PATH.new" "$CURRENT_THEME_PATH"
-~/.config/hyprtheme/scripts/theme-bg-next
-
-pkill -x waybar || true
-setsid uwsm-app -- waybar >/dev/null 2>&1 &
-
-hyprctl reload >/dev/null 2>&1
-
-pkill -SIGUSR2 btop || true
-
-makoctl reload
-
-if [[ -f ~/.config/alacritty/alacritty.toml ]]; then
- touch ~/.config/alacritty/alacritty.toml
-fi
-killall -SIGUSR1 kitty >/dev/null 2>&1 || true
-killall -SIGUSR2 ghostty >/dev/null 2>&1 || true
-
-if [[ -f ~/.config/hyprtheme/current/light.mode ]]; then
- gsettings set org.gnome.desktop.interface color-scheme "prefer-light"
- gsettings set org.gnome.desktop.interface gtk-theme "Adwaita"
- gsettings set org.gnome.desktop.interface font-name "Noto Sans"
-else
- gsettings set org.gnome.desktop.interface color-scheme "prefer-dark"
- gsettings set org.gnome.desktop.interface gtk-theme "Adwaita-dark"
- gsettings set org.gnome.desktop.interface font-name "Noto Sans"
-fi
diff --git a/roles/hyprtheme/files/scripts/theme.sh b/roles/hyprtheme/files/scripts/theme.sh
new file mode 100755
index 00000000..14be33c7
--- /dev/null
+++ b/roles/hyprtheme/files/scripts/theme.sh
@@ -0,0 +1,67 @@
+#!/bin/bash
+
+show_themes() {
+ local available_themes=$(ls -1p $HOME/.config/hyprtheme/themes/ | grep "/" | cut -f1 -d'/')
+ local selected_theme=$(printf "$available_themes" | tofi \
+ --prompt-text "Select: " \
+ --placeholder-text "Theme"
+ )
+
+ if [[ -n "$selected_theme" ]]; then
+ select_theme "$selected_theme"
+ fi
+}
+
+select_theme() {
+ local theme_name="$1"
+ local themes_path="$HOME/.config/hyprtheme/themes"
+ local current_theme_path="$HOME/.config/hyprtheme/current"
+
+ if [[ ! -d "$themes_path/$theme_name" ]]; then
+ notify-send -e \
+ -h string:x-canonical-private-synchronous:themes \
+ -u critical \
+ "Theme" \
+ "Theme '$theme_name' doesn't exist"
+ exit 1
+ fi
+
+ # Get close to as atomic as possible.
+ ln -sfn "$themes_path/$theme_name" "$current_theme_path.new"
+ rm -rf "$current_theme_path"
+ mv "$current_theme_path.new" "$current_theme_path"
+
+ # Prompt wallpaper selection
+ "$HOME/.config/hyprtheme/scripts/wallpaper.sh" #$(find "$current_theme_path/wallpapers" -type f | head -1)
+
+ pkill -x waybar || true
+ setsid uwsm-app -- waybar >/dev/null 2>&1 &
+
+ hyprctl reload >/dev/null 2>&1
+
+ pkill -SIGUSR2 btop || true
+
+ makoctl reload
+
+ if [[ -f ~/.config/alacritty/alacritty.toml ]]; then
+ touch ~/.config/alacritty/alacritty.toml
+ fi
+ killall -SIGUSR1 kitty >/dev/null 2>&1 || true
+ killall -SIGUSR2 ghostty >/dev/null 2>&1 || true
+
+ if [[ -f ~/.config/hyprtheme/current/light.mode ]]; then
+ gsettings set org.gnome.desktop.interface color-scheme "prefer-light"
+ gsettings set org.gnome.desktop.interface gtk-theme "Adwaita"
+ gsettings set org.gnome.desktop.interface font-name "Noto Sans"
+ else
+ gsettings set org.gnome.desktop.interface color-scheme "prefer-dark"
+ gsettings set org.gnome.desktop.interface gtk-theme "Adwaita-dark"
+ gsettings set org.gnome.desktop.interface font-name "Noto Sans"
+ fi
+}
+
+if [[ -z "$1" ]]; then
+ show_themes
+else
+ select_theme "$1"
+fi
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
diff --git a/roles/hyprtheme/files/themes/catppuccin/backgrounds/a_flower_on_a_dark_background.png b/roles/hyprtheme/files/themes/catppuccin/wallpapers/a_flower_on_a_dark_background.png
index 4090f188..4090f188 100644
--- a/roles/hyprtheme/files/themes/catppuccin/backgrounds/a_flower_on_a_dark_background.png
+++ b/roles/hyprtheme/files/themes/catppuccin/wallpapers/a_flower_on_a_dark_background.png
Binary files differ
diff --git a/roles/hyprtheme/files/themes/catppuccin/backgrounds/leef_dark_purple_minimalist.png b/roles/hyprtheme/files/themes/catppuccin/wallpapers/leef_dark_purple_minimalist.png
index be374e28..be374e28 100644
--- a/roles/hyprtheme/files/themes/catppuccin/backgrounds/leef_dark_purple_minimalist.png
+++ b/roles/hyprtheme/files/themes/catppuccin/wallpapers/leef_dark_purple_minimalist.png
Binary files differ
diff --git a/roles/hyprtheme/files/themes/everforest/backgrounds/1-a_pile_of_cut_logs.jpg b/roles/hyprtheme/files/themes/everforest/wallpapers/1-a_pile_of_cut_logs.jpg
index 166101a3..166101a3 100644
--- a/roles/hyprtheme/files/themes/everforest/backgrounds/1-a_pile_of_cut_logs.jpg
+++ b/roles/hyprtheme/files/themes/everforest/wallpapers/1-a_pile_of_cut_logs.jpg
Binary files differ
diff --git a/roles/hyprtheme/files/themes/everforest/backgrounds/2-everforest.jpg b/roles/hyprtheme/files/themes/everforest/wallpapers/2-everforest.jpg
index 6d75259d..6d75259d 100644
--- a/roles/hyprtheme/files/themes/everforest/backgrounds/2-everforest.jpg
+++ b/roles/hyprtheme/files/themes/everforest/wallpapers/2-everforest.jpg
Binary files differ
diff --git a/roles/hyprtheme/files/themes/gruvbox/backgrounds/2-gruvbox.jpg b/roles/hyprtheme/files/themes/gruvbox/wallpapers/2-gruvbox.jpg
index fd318699..fd318699 100644
--- a/roles/hyprtheme/files/themes/gruvbox/backgrounds/2-gruvbox.jpg
+++ b/roles/hyprtheme/files/themes/gruvbox/wallpapers/2-gruvbox.jpg
Binary files differ
diff --git a/roles/hyprtheme/files/themes/gruvbox/backgrounds/a_road_surrounded_by_trees.jpg b/roles/hyprtheme/files/themes/gruvbox/wallpapers/a_road_surrounded_by_trees.jpg
index 4944aa28..4944aa28 100644
--- a/roles/hyprtheme/files/themes/gruvbox/backgrounds/a_road_surrounded_by_trees.jpg
+++ b/roles/hyprtheme/files/themes/gruvbox/wallpapers/a_road_surrounded_by_trees.jpg
Binary files differ
diff --git a/roles/hyprtheme/files/themes/matte-black/backgrounds/0-ship-at-sea.jpg b/roles/hyprtheme/files/themes/matte-black/wallpapers/0-ship-at-sea.jpg
index 4375ee2b..4375ee2b 100644
--- a/roles/hyprtheme/files/themes/matte-black/backgrounds/0-ship-at-sea.jpg
+++ b/roles/hyprtheme/files/themes/matte-black/wallpapers/0-ship-at-sea.jpg
Binary files differ
diff --git a/roles/hyprtheme/files/themes/matte-black/backgrounds/1-matte-black.jpg b/roles/hyprtheme/files/themes/matte-black/wallpapers/1-matte-black.jpg
index 2afb1bcb..2afb1bcb 100644
--- a/roles/hyprtheme/files/themes/matte-black/backgrounds/1-matte-black.jpg
+++ b/roles/hyprtheme/files/themes/matte-black/wallpapers/1-matte-black.jpg
Binary files differ
diff --git a/roles/hyprtheme/files/themes/matte-black/backgrounds/2-matte-black-hands.jpg b/roles/hyprtheme/files/themes/matte-black/wallpapers/2-matte-black-hands.jpg
index b76792cb..b76792cb 100644
--- a/roles/hyprtheme/files/themes/matte-black/backgrounds/2-matte-black-hands.jpg
+++ b/roles/hyprtheme/files/themes/matte-black/wallpapers/2-matte-black-hands.jpg
Binary files differ
diff --git a/roles/hyprtheme/files/themes/osaka-jade/backgrounds/3-osaka-jade-bg.jpg b/roles/hyprtheme/files/themes/osaka-jade/wallpapers/3-osaka-jade-bg.jpg
index 729ccae4..729ccae4 100644
--- a/roles/hyprtheme/files/themes/osaka-jade/backgrounds/3-osaka-jade-bg.jpg
+++ b/roles/hyprtheme/files/themes/osaka-jade/wallpapers/3-osaka-jade-bg.jpg
Binary files differ
diff --git a/roles/hyprtheme/files/themes/ristretto/backgrounds/1-ristretto.jpg b/roles/hyprtheme/files/themes/ristretto/wallpapers/1-ristretto.jpg
index 7618e1b5..7618e1b5 100644
--- a/roles/hyprtheme/files/themes/ristretto/backgrounds/1-ristretto.jpg
+++ b/roles/hyprtheme/files/themes/ristretto/wallpapers/1-ristretto.jpg
Binary files differ
diff --git a/roles/hyprtheme/files/themes/ristretto/backgrounds/2-ristretto.jpg b/roles/hyprtheme/files/themes/ristretto/wallpapers/2-ristretto.jpg
index faf63eab..faf63eab 100644
--- a/roles/hyprtheme/files/themes/ristretto/backgrounds/2-ristretto.jpg
+++ b/roles/hyprtheme/files/themes/ristretto/wallpapers/2-ristretto.jpg
Binary files differ
diff --git a/roles/hyprtheme/files/themes/ristretto/backgrounds/3-ristretto.jpg b/roles/hyprtheme/files/themes/ristretto/wallpapers/3-ristretto.jpg
index 385b01d9..385b01d9 100644
--- a/roles/hyprtheme/files/themes/ristretto/backgrounds/3-ristretto.jpg
+++ b/roles/hyprtheme/files/themes/ristretto/wallpapers/3-ristretto.jpg
Binary files differ
diff --git a/roles/hyprtheme/files/themes/tokyo-night/backgrounds/1-scenery-pink-lakeside-sunset-lake-landscape-scenic-panorama-7680x3215-144.png b/roles/hyprtheme/files/themes/tokyo-night/wallpapers/1-scenery-pink-lakeside-sunset-lake-landscape-scenic-panorama-7680x3215-144.png
index d8067288..d8067288 100644
--- a/roles/hyprtheme/files/themes/tokyo-night/backgrounds/1-scenery-pink-lakeside-sunset-lake-landscape-scenic-panorama-7680x3215-144.png
+++ b/roles/hyprtheme/files/themes/tokyo-night/wallpapers/1-scenery-pink-lakeside-sunset-lake-landscape-scenic-panorama-7680x3215-144.png
Binary files differ
diff --git a/roles/hyprtheme/tasks/main.yml b/roles/hyprtheme/tasks/main.yml
index a31cd296..fd7a1734 100644
--- a/roles/hyprtheme/tasks/main.yml
+++ b/roles/hyprtheme/tasks/main.yml
@@ -30,8 +30,8 @@
dest: "{{ ansible_facts['env']['HOME'] }}/.config/hyprtheme/{{ item }}"
mode: "0755"
loop:
- - "scripts/theme-set"
- - "scripts/theme-bg-next"
+ - "scripts/theme.sh"
+ - "scripts/wallpaper.sh"
- name: "Set default theme"
ansible.builtin.command:
@@ -40,6 +40,6 @@
# This will ignore the errors in the script, because the script restarts some hyprland services, which
# will fail on ssh connection, but having the theme files placed in the right directory will make sure that
# the first setup of hyprtheme is working and doesn't show errors on first boot
- cmd: "{{ ansible_facts['env']['HOME'] }}/.config/hyprtheme/scripts/theme-set {{ hyprtheme_default_theme }}"
+ cmd: "{{ ansible_facts['env']['HOME'] }}/.config/hyprtheme/scripts/theme.sh {{ hyprtheme_default_theme }}"
creates: "{{ ansible_facts['env']['HOME'] }}/.config/hyprtheme/current/hyprland.conf"
failed_when: false