Setup script to listen for theme changes and call swap mode as needed

This commit is contained in:
Alex Selimov 2026-01-15 22:29:22 -05:00
parent cc70db25c6
commit 1fffc14cf7
Signed by: aselimov
GPG key ID: 3DDB9C3E023F1F31

19
bin/listen_theme_changes.sh Executable file
View file

@ -0,0 +1,19 @@
#!/bin/bash
# Directory where the script is located
SCRIPT_DIR="$(dirname "$(realpath "$0")")"
SWAP_MODE_SCRIPT="$SCRIPT_DIR/swap_mode.sh"
# Listen for changes in the color-scheme setting
gsettings monitor org.gnome.desktop.interface color-scheme | while read -r line; do
# 'default' usually corresponds to light mode in GNOME
if [[ "$line" == *"default"* ]]; then
echo "Detected light mode change..."
"$SWAP_MODE_SCRIPT" light
# 'prefer-dark' corresponds to dark mode
elif [[ "$line" == *"prefer-dark"* ]]; then
echo "Detected dark mode change..."
"$SWAP_MODE_SCRIPT" dark
fi
done