Commit 8cbcef24 authored by Roman Alifanov's avatar Roman Alifanov

added reaction mode: after changes in config file

parent cac35223
...@@ -28,6 +28,23 @@ cfg_check() { ...@@ -28,6 +28,23 @@ cfg_check() {
fi fi
} }
check_gsettings_schema() {
local SCHEMA="org.gnome.desktop.interface"
local KEY="color-scheme"
if gsettings list-schemas | grep -q "$SCHEMA"; then
if gsettings list-keys "$SCHEMA" | grep -q "$KEY"; then
echo "Schema '$SCHEMA' and KEY '$KEY' exist."
return 0
else
echo "Schema '$SCHEMA' exists, but KEY '$KEY' not found."
return 1
fi
else
echo "Schema '$SCHEMA' not found."
return 1
fi
}
update_kv_theme() { update_kv_theme() {
echo "Updating Kvantum theme to $1..." echo "Updating Kvantum theme to $1..."
...@@ -80,21 +97,32 @@ check_and_update_themes() { ...@@ -80,21 +97,32 @@ check_and_update_themes() {
check_and_update_themes check_and_update_themes
main() { main() {
local COUNT=0 if check_gsettings_schema; then
dbus-monitor "interface='org.freedesktop.portal.Settings',member=SettingChanged" | \ echo "reaction mode: after dbus signal"
while IFS= read -r LINE; do local COUNT=0
local THEME dbus-monitor "interface='org.freedesktop.portal.Settings',member=SettingChanged" | \
THEME=$(echo "$LINE" | grep -E -o 'string "(prefer-dark|default)"') while IFS= read -r LINE; do
local THEME
if [ -n "$THEME" ]; then THEME=$(echo "$LINE" | grep -E -o 'string "(prefer-dark|default)"')
((COUNT++))
if [ -n "$THEME" ]; then
if [ $(($COUNT % 2)) = 0 ]; then ((COUNT++))
echo "$THEME"
check_and_update_themes if [ $(($COUNT % 2)) = 0 ]; then
COUNT=0 echo "$THEME"
check_and_update_themes
COUNT=0
fi
fi fi
fi done
done else
echo "reaction mode: after changes in config file"
local CONFIG_FILE=$(cfg_check)
inotifywait -m -e modify "$CONFIG_FILE" | \
while read -r directory events filename; do
check_and_update_themes
done
fi
} }
main main
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment