aboutsummaryrefslogtreecommitdiffstats
path: root/desktop
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-19 10:08:37 +0200
committerDanilo M. <danix@danix.xyz>2026-10-19 10:08:37 +0200
commit6ccdad992e7a62e92f3a67c3e370646f787aefd9 (patch)
tree0e0a4405d0b6930d290ec68a10387da74f569690 /desktop
parentd9c9c30865330b24349438e4e20579fd76dafbd5 (diff)
downloadquickshell-6ccdad992e7a62e92f3a67c3e370646f787aefd9.tar.gz
quickshell-6ccdad992e7a62e92f3a67c3e370646f787aefd9.zip
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 <noreply@anthropic.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/modules/notifications/NotificationsModule.qml17
1 files changed, 10 insertions, 7 deletions
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;
}
}