1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-06-16 16:15:23 -04:00

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
This commit is contained in:
Rocho
2026-06-16 18:49:51 +02:00
committed by GitHub
parent cb29125580
commit 90f8ce5035
4 changed files with 29 additions and 6 deletions
+1
View File
@@ -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
@@ -282,6 +282,7 @@ var SPEC = {
soundNewNotification: { def: true },
soundVolumeChanged: { def: true },
soundPluggedIn: { def: true },
muteSoundsWhenMediaPlaying: { def: true },
acMonitorTimeout: { def: 0 },
acLockTimeout: { def: 0 },
+17
View File
@@ -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)
}
}
}
+10 -6
View File
@@ -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();