commit 26e2119bd4d6982d3aa3479539e02c2c07b55bd3
parent b3619a98dd41cdef22d237cedd550282dbffde58
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date: Sat, 18 Apr 2026 09:28:30 +0200
feat: handle terminal theme switches properly
Diffstat:
2 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/switch-themes.sh b/switch-themes.sh
@@ -13,13 +13,13 @@ if [ -f "./gnome-switch-theme.sh" ]; then
./gnome-switch-theme.sh "$1"
fi
-## Helix
-if [ -f "./helix-switch-theme.sh" ]; then
- ./helix-switch-theme.sh "$1"
-fi
-
## Bash
if [ -f "./term-switch-theme.sh" ]; then
./term-switch-theme.sh "$1"
fi
+## Helix
+if [ -f "./helix-switch-theme.sh" ]; then
+ ./helix-switch-theme.sh "$1"
+fi
+
diff --git a/term-switch-theme.sh b/term-switch-theme.sh
@@ -10,13 +10,27 @@ if [[ ! -f /tmp/theme-switch-term-status ]]; then
touch /tmp/theme-switch-term-status
fi
-if [[ $(cat /tmp/theme-switch-term-status) == "$1" ]]; then
+if [ -z $1 ]; then
+ current=$(cat /tmp/theme-switch-term-status)
+ case $current in
+ "dark")
+ target="light"
+ ;;
+ "light")
+ target="dark"
+ ;;
+ esac
+else
+ target="$1"
+fi
+
+if [[ $(cat /tmp/theme-switch-term-status) == "$target" ]]; then
echo "[-] Did not switch theme: $1"
- # exit 0
+ exit 0
fi
# define theme color based on given input
-if [[ $1 == "dark" ]]; then
+if [[ "$target" == "dark" ]]; then
fg="#ffffff"
bg="#111111"
col0="#073642" # black
@@ -27,7 +41,7 @@ if [[ $1 == "dark" ]]; then
col5="#d33682" # magenta
col6="#2aa198" # cyan
col7="#eee8d5" # white
-elif [[ $1 == "light" ]]; then
+elif [[ "$target" == "light" ]]; then
fg="#000000"
bg="#f7f7f7"
col0="#08404f" # bright black
@@ -67,7 +81,7 @@ for i in $(pgrep $shell); do
done
# user output
-if [[ $(cat /tmp/theme-switch-term-status) != "$1" ]]; then
- echo "$1" | tee /tmp/theme-switch-term-status > /dev/null
- echo "[✓] Switched $shell to $1!"
+if [[ $(cat /tmp/theme-switch-term-status) != "$target" ]]; then
+ echo "$target" | tee /tmp/theme-switch-term-status > /dev/null
+ echo "[✓] Switched $shell to $target!"
fi