diff --git a/bin/listen_theme_changes.sh b/bin/listen_theme_changes.sh new file mode 100755 index 0000000..b5952d9 --- /dev/null +++ b/bin/listen_theme_changes.sh @@ -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