From 90f8ce5035fa2531ed813736403b37d0da4f6731 Mon Sep 17 00:00:00 2001 From: Rocho Date: Tue, 16 Jun 2026 18:49:51 +0200 Subject: [PATCH] feat(sounds): make muting sounds during media playback configurable (#2652) Commit e3dbaed started skipping all system sounds (notifications, volume, power, login) whenever an MPRIS player is playing, with no way to opt out. Users who rely on notification sounds while listening to music lost them entirely. Add a 'Mute During Playback' toggle (SettingsData.muteSoundsWhenMediaPlaying, default true) so the current behaviour is preserved, but users can disable it to restore audible sounds while media is playing. The media check is wrapped in shouldMuteForMedia(), which gates on the new setting before querying the active player. Closes #2616 --- quickshell/Common/SettingsData.qml | 1 + quickshell/Common/settings/SettingsSpec.js | 1 + quickshell/Modules/Settings/SoundsTab.qml | 17 +++++++++++++++++ quickshell/Services/AudioService.qml | 16 ++++++++++------ 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/quickshell/Common/SettingsData.qml b/quickshell/Common/SettingsData.qml index 7695144f..acb23f20 100644 --- a/quickshell/Common/SettingsData.qml +++ b/quickshell/Common/SettingsData.qml @@ -572,6 +572,7 @@ Singleton { property bool soundVolumeChanged: true property bool soundPluggedIn: true property bool soundLogin: false + property bool muteSoundsWhenMediaPlaying: true property int acMonitorTimeout: 0 property int acLockTimeout: 0 diff --git a/quickshell/Common/settings/SettingsSpec.js b/quickshell/Common/settings/SettingsSpec.js index f5484cb0..166e78de 100644 --- a/quickshell/Common/settings/SettingsSpec.js +++ b/quickshell/Common/settings/SettingsSpec.js @@ -282,6 +282,7 @@ var SPEC = { soundNewNotification: { def: true }, soundVolumeChanged: { def: true }, soundPluggedIn: { def: true }, + muteSoundsWhenMediaPlaying: { def: true }, acMonitorTimeout: { def: 0 }, acLockTimeout: { def: 0 }, diff --git a/quickshell/Modules/Settings/SoundsTab.qml b/quickshell/Modules/Settings/SoundsTab.qml index a8e9958f..453f0d61 100644 --- a/quickshell/Modules/Settings/SoundsTab.qml +++ b/quickshell/Modules/Settings/SoundsTab.qml @@ -131,6 +131,23 @@ Item { checked: SettingsData.soundPluggedIn onToggled: checked => SettingsData.set("soundPluggedIn", checked) } + + Rectangle { + width: parent.width + height: 1 + color: Theme.outline + opacity: 0.2 + } + + SettingsToggleRow { + tab: "sounds" + tags: ["sound", "media", "playback", "mute", "mpris", "music"] + settingKey: "muteSoundsWhenMediaPlaying" + text: I18n.tr("Mute During Playback") + description: I18n.tr("Silence system sounds while media is playing") + checked: SettingsData.muteSoundsWhenMediaPlaying + onToggled: checked => SettingsData.set("muteSoundsWhenMediaPlaying", checked) + } } } diff --git a/quickshell/Services/AudioService.qml b/quickshell/Services/AudioService.qml index 065f6535..9b08c24c 100644 --- a/quickshell/Services/AudioService.qml +++ b/quickshell/Services/AudioService.qml @@ -589,38 +589,42 @@ EOFCONFIG return MprisController.activePlayer?.isPlaying ?? false; } + function shouldMuteForMedia() { + return SettingsData.muteSoundsWhenMediaPlaying && isMediaPlaying(); + } + function playVolumeChangeSound() { - if (!soundsAvailable || !volumeChangeSound || notificationsAudioMuted || isMediaPlaying()) + if (!soundsAvailable || !volumeChangeSound || notificationsAudioMuted || shouldMuteForMedia()) return; volumeChangeSound.play(); } function playPowerPlugSound() { - if (!soundsAvailable || !powerPlugSound || notificationsAudioMuted || isMediaPlaying()) + if (!soundsAvailable || !powerPlugSound || notificationsAudioMuted || shouldMuteForMedia()) return; powerPlugSound.play(); } function playPowerUnplugSound() { - if (!soundsAvailable || !powerUnplugSound || notificationsAudioMuted || isMediaPlaying()) + if (!soundsAvailable || !powerUnplugSound || notificationsAudioMuted || shouldMuteForMedia()) return; powerUnplugSound.play(); } function playNormalNotificationSound() { - if (!soundsAvailable || !normalNotificationSound || SessionData.doNotDisturb || notificationsAudioMuted || isMediaPlaying()) + if (!soundsAvailable || !normalNotificationSound || SessionData.doNotDisturb || notificationsAudioMuted || shouldMuteForMedia()) return; normalNotificationSound.play(); } function playCriticalNotificationSound() { - if (!soundsAvailable || !criticalNotificationSound || SessionData.doNotDisturb || notificationsAudioMuted || isMediaPlaying()) + if (!soundsAvailable || !criticalNotificationSound || SessionData.doNotDisturb || notificationsAudioMuted || shouldMuteForMedia()) return; criticalNotificationSound.play(); } function playLoginSound() { - if (!soundsAvailable || !loginSound || notificationsAudioMuted || isMediaPlaying()) { + if (!soundsAvailable || !loginSound || notificationsAudioMuted || shouldMuteForMedia()) { return; } loginSound.play();