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() {
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() {
echo "Updating Kvantum theme to $1..."
......@@ -80,21 +97,32 @@ check_and_update_themes() {
check_and_update_themes
main() {
local COUNT=0
dbus-monitor "interface='org.freedesktop.portal.Settings',member=SettingChanged" | \
while IFS= read -r LINE; do
local THEME
THEME=$(echo "$LINE" | grep -E -o 'string "(prefer-dark|default)"')
if [ -n "$THEME" ]; then
((COUNT++))
if [ $(($COUNT % 2)) = 0 ]; then
echo "$THEME"
check_and_update_themes
COUNT=0
if check_gsettings_schema; then
echo "reaction mode: after dbus signal"
local COUNT=0
dbus-monitor "interface='org.freedesktop.portal.Settings',member=SettingChanged" | \
while IFS= read -r LINE; do
local THEME
THEME=$(echo "$LINE" | grep -E -o 'string "(prefer-dark|default)"')
if [ -n "$THEME" ]; then
((COUNT++))
if [ $(($COUNT % 2)) = 0 ]; then
echo "$THEME"
check_and_update_themes
COUNT=0
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
\ 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