Repository navigation
feat(notifications): respect system Do Not Disturb for WhatsApp's mes… - #1001
Merged
Merged
Conversation
the-beper
force-pushed
the
feat/respect-do-not-disturb
branch
from
November 11, 2026 18:14
4ec2aae to
0a5d90d
Compare
…sage tone Add DoNotDisturbMonitor (QtDBus), which reads the notification server's Inhibited property (KDE Plasma) and the portal show-banners setting (GNOME, not verified on a real session) and follows their changes, including a notification server that disappears or restarts. While Do Not Disturb is on and the new "Respect Do Not Disturb" setting (default on) is enabled, an injected script makes play() a no-op for WhatsApp Web's message tone only: a detached, non-looping <audio> served by static.whatsapp.net. Calls, voice notes and videos are unaffected. The state is baked into the script source so reloads start with the right value. The tone comes from the page, so neither the desktop notification hints nor the global mute covered this case (#896, #624). Add the two new strings to the catalogs with Italian and Brazilian Portuguese translations; the Turkish one needs a native review. Tests: - flatpak_python -m unittest discover -s tests -q: 781 tests, 8 failures that also fail without this change (dictionary UI, zh-CN catalog, macOS packaging script, account context menu) - flatpak_python tests/check_unused_code.py --packages-only - flatpak_python tests/test_documentation_structure.py -v - Manual on KDE Plasma (Flatpak build): no tone for a message with Do Not Disturb on; video and voice playback still audible. Live DND toggling, calls and GNOME were not tested. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refresh the POT template and every catalog after the rebase onto main so source references match the moved code. The merge surfaced the new single-process alert strings in the Turkish catalog as fuzzy or empty entries, which the Turkish guard test rejects; fill them with best-effort Turkish translations pending native review, as with the Do Not Disturb strings. Tests: - flatpak_python -m unittest discover -s tests -q - flatpak_python tests/check_unused_code.py --packages-only - flatpak_python tests/test_documentation_structure.py -v - flatpak_python -m compileall -q zapzap tests tools run.py - git diff --check
the-beper
force-pushed
the
feat/respect-do-not-disturb
branch
from
November 11, 2026 18:32
0a5d90d to
56b2a52
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AI disclosure
This PR has been assisted by Claude Code.
Summary
Silence WhatsApp Web's message tone while the desktop Do Not Disturb mode is on. New setting Respect Do Not Disturb (Notifications page,
notification/respect_dnd, default on).Fixes the tone still playing under DND: #896 (KDE Plasma), #624 (GNOME). Related: #864, #816.
Problem
The message tone is played by the WhatsApp Web page (
<audio>), not by the notification server. Existing controls do not cover it:suppress-sound/"sound": "silent"(Add a setting to mute the notification sound #816) only affect the desktop notification's own sound.system/audio_mutedmutes the whole page, including calls, voice notes and videos.Changes
DND detection (
features/notifications/do_not_disturb_monitor.py, QtDBus only, no new dependency).DoNotDisturbMonitor.activeis true when any available source reports DND, andchanged(bool)fires on transitions.org.freedesktop.Notifications(KDE Plasma, any server implementing it)Properties.Get(..., "Inhibited")PropertiesChangedInhibited == trueSettings.Read("org.gnome.desktop.notifications", "show-banners")SettingChangedshow-banners == falseQDBusMessage.createMethodCallwith a 1 s block timeout: no introspection, no long stall on the GUI thread.NameOwnerChangedfororg.freedesktop.Notifications: owner gone resets the inhibition (no stuck-silent state if plasmashell restarts); new owner re-reads.--talk-name=org.freedesktop.Notificationsis already granted and the portal is always reachable.Tone suppression (
features/browser/web/scripts/notification_sound_guard.js). WrapsHTMLMediaElement.prototype.playand returns a resolvedPromisewithout playing when suppression is active and the element matches all of:tagName === "AUDIO"!isConnected)!loopcurrentSrc/srcstarts withhttps://static.whatsapp.net/Voice notes (
blob:sources), videos (attached<video>) and the looping call ringtone do not match. Anything unrecognised plays normally (fails open). The matcher was derived fromplay()calls logged on a live session (see Testing).Registered per profile at
DocumentCreation,MainWorld, main frame only. The initial state is prefixed to the script source (window.__zapzapNotificationSoundInitial), and the script is re-registered on every state change, so a reload or a new document never starts unmuted. The live document is updated withrunJavaScript.State ownership.
MainWindowControllercomputesrespect_dnd and monitor.active(runtime only, not persisted) and fans it out viaBrowserController.set_notification_sound_suppressed→WebView→PageController, following the existingset_audio_mutedpath. Accounts created later inherit the current state.system/audio_mutedandnotification/soundare untouched and independent.Setting.
NotificationSettings.respect_dndplus anotification_settings_events.respect_dnd_changedsignal (same pattern asdownload_settings_events) so toggling applies immediately. The switch sits outside the group that depends on "Desktop notifications", because the page plays the tone even with desktop notifications disabled.Translations. Two new msgids added to
zapzap.potand all.pofiles (msgmerge, minimal diff). Translated forit,pt_BRandtr; their.mofiles are rebuilt. Other catalogs keep emptymsgstrand fall back to English.Docs.
docs/testing.md: test inventory entries and a manual DND validation checklist.Testing
Run in the official Flatpak environment.
unittest discover -s tests -q: 781 tests. 8 failures/errors, none related to this change: dictionary manager/options UI, zh-CN catalog, macOS packaging script, account context menu. Checked on the author's working tree, not on a clean upstreammain.check_unused_code.py --packages-only,test_documentation_structure.py,compileall,git diff --check: pass.test_do_not_disturb_monitor.py: transitions emit once, unrelated interfaces/keys ignored, nested-variant and error replies, server owner loss/return, no-op off Linux.test_notification_sound_guard.py: script in a realQWebEnginePage(message tone silenced; looping ringtone,blob:audio, attached<video>and attached<audio>pass; initial state; suppression lifted again) and per-account fan-out throughMainWindowController.test_notifications_settings_ui.py: switch persists and stays enabled when desktop notifications are off.play()log used to derive the matcher came from the same session.Inhibitedverified to exist on Plasma (busctl), and the monitor's read verified inside the sandbox.Not verified
org.gnome.desktop.notificationsat all. If not, the GNOME source is simply unavailable.static.whatsapp.netaudio, which may include the sent-message sound (not checked).play()fires noended/pauseevent; whether WhatsApp Web waits for one was not checked.