aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfig/hypr/scripts/ThemeChanger.sh54
-rwxr-xr-xconfig/hypr/scripts/ThemeChanger.sh.ori27
2 files changed, 67 insertions, 14 deletions
diff --git a/config/hypr/scripts/ThemeChanger.sh b/config/hypr/scripts/ThemeChanger.sh
index 15534258..0843fd69 100755
--- a/config/hypr/scripts/ThemeChanger.sh
+++ b/config/hypr/scripts/ThemeChanger.sh
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
-
set -euo pipefail
# SPDX-FileCopyrightText: 2025-present Ahum Maitra theahummaitra@gmail.com
@@ -8,20 +7,47 @@ set -euo pipefail
# Repository url : https://github.com/TheAhumMaitra/cautious-waddle
-# User choice
-choice=$(wallust theme list \
- | sed '1d' \
- | sed 's/^- //' \
- | rofi -dmenu -p "Select Global Theme")
+require() {
+ command -v "$1" >/dev/null 2>&1 || {
+ printf '%s\n' "Missing dependency: $1" >&2
+ exit 127
+ }
+}
+
+require wallust
+require rofi
+
+# notify-send is optional
+have_notify() { command -v notify-send >/dev/null 2>&1; }
-# If user requested to exit, then exit
-[[ -z "$choice" ]] && exit 0
+# Prompt for theme; guard -e on cancel
+set +e
+choice="$(wallust theme list \
+ | sed -e '1d' -e 's/^- //' \
+ | rofi -dmenu -i -p 'Select Global Theme')"
+prompt_status=$?
+set -e
-# Apply the theme
-wallust theme "$choice"
+# Exit cleanly on cancel or empty selection
+if (( prompt_status != 0 )) || [[ -z "${choice}" ]]; then
+ exit 0
+fi
-# Inform user about theme changed
-notify-send "Global theme changed" "Global Theme selected $choice"
+# Apply the theme and report result
+if wallust theme -- "${choice}"; then
+ have_notify && notify-send -a ThemeChanger \
+ -h string:x-dunst-stack-tag:themechanger \
+ "Global theme changed" "Selected: ${choice}"
-# Give warning to user for Waybar theme refresh
-notify-send "Press SUPER+ALT+R to Refresh Waybar Theme"
+ # Try to refresh Waybar automatically; ignore failures
+ if command -v waybar-msg >/dev/null 2>&1; then
+ waybar-msg cmd reload >/dev/null 2>&1 || true
+ else
+ pkill -SIGUSR2 waybar >/dev/null 2>&1 || true
+ fi
+else
+ have_notify && notify-send -u critical -a ThemeChanger \
+ -h string:x-dunst-stack-tag:themechanger \
+ "Failed to apply theme" "${choice}"
+ exit 1
+fi
diff --git a/config/hypr/scripts/ThemeChanger.sh.ori b/config/hypr/scripts/ThemeChanger.sh.ori
new file mode 100755
index 00000000..15534258
--- /dev/null
+++ b/config/hypr/scripts/ThemeChanger.sh.ori
@@ -0,0 +1,27 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+# SPDX-FileCopyrightText: 2025-present Ahum Maitra theahummaitra@gmail.com
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+# Repository url : https://github.com/TheAhumMaitra/cautious-waddle
+
+# User choice
+choice=$(wallust theme list \
+ | sed '1d' \
+ | sed 's/^- //' \
+ | rofi -dmenu -p "Select Global Theme")
+
+# If user requested to exit, then exit
+[[ -z "$choice" ]] && exit 0
+
+# Apply the theme
+wallust theme "$choice"
+
+# Inform user about theme changed
+notify-send "Global theme changed" "Global Theme selected $choice"
+
+# Give warning to user for Waybar theme refresh
+notify-send "Press SUPER+ALT+R to Refresh Waybar Theme"
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage