Commit 3593abc4 authored by Roman Alifanov's avatar Roman Alifanov

fix: debounce and deduplicate D-Bus theme updates

Increase debounce from 150ms to 1000ms and skip updates when theme hasn't changed. Deduplicate plugin list to prevent double apply when plugins are loaded from both system and user directories.
parent d64a898a
......@@ -50,6 +50,7 @@ func run_file_reaction () {
func run_dbus_reaction () {
print ("reaction mode: after dbus signal")
last_update = 0
last_theme = ""
proc = async dbus-monitor ("interface='org.freedesktop.portal.Settings',member=SettingChanged")
foreach line in proc {
......@@ -57,11 +58,14 @@ func run_dbus_reaction () {
if !is_empty (theme) {
current_time = date ("+%s%3N")
diff = current_time - last_update
if diff >= 150 {
last_update = current_time
if diff >= 1000 {
new_theme = gsettings ("get", "org.gnome.desktop.interface", "color-scheme") | awk ("-F'", "\{print $2\}")
print ("D-Bus signal detected: {theme}")
check_and_update_themes (new_theme)
if new_theme != last_theme {
last_update = current_time
last_theme = new_theme
print ("D-Bus signal detected: {theme}")
check_and_update_themes (new_theme)
}
}
}
}
......
......@@ -7,8 +7,10 @@ if fs.exists (HOME_PLUGIN_DIR) {
}
func themes_init_defaults (cfg_path: string) {
seen = {}
foreach name in plugin.list ().split (" ") {
if !is_empty (name) {
if !is_empty (name) && !seen.has (name) {
seen.set (name, true)
if plugin.has (name, "prefix") {
prefix = plugin.call (name, "prefix")
light_key = prefix .. "_LIGHT_THEME"
......@@ -28,8 +30,10 @@ func themes_update (mode: string, cfg_path: string) {
suffix = "_DARK_THEME"
}
seen = {}
foreach name in plugin.list ().split (" ") {
if !is_empty (name) {
if !is_empty (name) && !seen.has (name) {
seen.set (name, true)
available = plugin.call (name, "is_available")
if available == "true" {
if plugin.has (name, "prefix") {
......
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