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();