From 6ccdad992e7a62e92f3a67c3e370646f787aefd9 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Mon, 19 Oct 2026 10:08:37 +0200 Subject: notifications: write gsettings only when the theme changed From the final review. Every save ran gsettings set, so saving a timeout on a first run, with no soundTheme in the file, silently reset a system theme set elsewhere to freedesktop; the page now writes it only when the draft's theme differs from the file's, and flags any other mismatch as before. An exit code outside 0-3, a save killed mid-run, now reads as an error rather than a partial success. The player's comment no longer claims the balloon's expiry check, which it does not need. Co-Authored-By: Claude Opus 5.5 --- desktop/modules/notifications/NotificationsModule.qml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'desktop/modules/notifications/NotificationsModule.qml') diff --git a/desktop/modules/notifications/NotificationsModule.qml b/desktop/modules/notifications/NotificationsModule.qml index df52949..f1fac3a 100644 --- a/desktop/modules/notifications/NotificationsModule.qml +++ b/desktop/modules/notifications/NotificationsModule.qml @@ -52,7 +52,10 @@ Module { // Unknown keys in the file survive, including inside timeouts and // balloons, which are merged one level down. The text goes on stdin to // cat (the notes pattern: the exit code is the outcome); 1 is the write, - // 3 the gsettings theme, 2 the reload, so a stopped daemon reads as saved-but-not-applied. + // 2 the reload, so a stopped daemon reads as saved-but-not-applied, and 3 + // the gsettings theme (2 wins when both fail). gsettings is written only + // when the theme itself changed: saving a timeout must not reset a system + // theme changed elsewhere, which the page flags instead. // Written in onStarted, then stdinEnabled cleared to give cat its EOF: // the sequence notes' bodyWriter uses (NotesModule.qml). function save() { @@ -65,7 +68,7 @@ Module { balloons: Object.assign({}, obj(raw.balloons), nm.draft.balloons), sounds: Object.assign({}, obj(raw.sounds), nm.draft.sounds), }); - nm.saver.theme = nm.draft.soundTheme; + nm.saver.theme = nm.draft.soundTheme !== Notify.config.soundTheme ? nm.draft.soundTheme : ""; nm.saver.data = JSON.stringify(out, null, 2) + "\n"; nm.saver.stdinEnabled = true; nm.saver.running = false; @@ -76,7 +79,7 @@ Module { property string theme: "" command: ["sh", "-c", 'mkdir -p "$(dirname "$1")" && cat > "$1" || exit 1; ' - + 'gsettings set org.gnome.desktop.sound theme-name "$2" || g=3; ' + + '{ [ -z "$2" ] || gsettings set org.gnome.desktop.sound theme-name "$2"; } || g=3; ' + 'notifyctl reload || exit 2; exit ${g:-0}', "sh", Notify.configPath, nm.saver.theme] onStarted: { @@ -84,10 +87,10 @@ Module { nm.saver.stdinEnabled = false; } onExited: code => { - if (code === 1) nm.error = "could not write config.json"; - else nm.notice = code === 0 ? "saved" - : code === 2 ? "saved; notifyd not running, it reads it at start" - : "saved; system sound theme not set"; + if (code === 0) nm.notice = "saved"; + else if (code === 2) nm.notice = "saved; notifyd not running, it reads it at start"; + else if (code === 3) nm.notice = "saved; system sound theme not set"; + else nm.error = code === 1 ? "could not write config.json" : "save interrupted"; nm.gsGet.running = false; nm.gsGet.running = true; } } -- cgit v1.2.3