1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-15 10:12:07 -04:00

audio: disable effects when mpris player is playing

This commit is contained in:
bbedward
2026-02-23 12:31:04 -05:00
parent 9f17ced6de
commit e3dbaedbb4

View File

@@ -32,11 +32,7 @@ Singleton {
property var mediaDevicesConnections: null property var mediaDevicesConnections: null
property var deviceAliases: ({}) property var deviceAliases: ({})
property string wireplumberConfigPath: { property string wireplumberConfigPath: Paths.strip(StandardPaths.writableLocation(StandardPaths.ConfigLocation)) + "/wireplumber/wireplumber.conf.d/51-dms-audio-aliases.conf"
const homeUrl = StandardPaths.writableLocation(StandardPaths.HomeLocation);
const homePath = homeUrl.toString().replace("file://", "");
return homePath + "/.config/wireplumber/wireplumber.conf.d/51-dms-audio-aliases.conf";
}
property bool wireplumberReloading: false property bool wireplumberReloading: false
readonly property int sinkMaxVolume: { readonly property int sinkMaxVolume: {
@@ -146,9 +142,7 @@ Singleton {
} }
function writeWireplumberConfig() { function writeWireplumberConfig() {
const homeUrl = StandardPaths.writableLocation(StandardPaths.HomeLocation); const configDir = Paths.strip(StandardPaths.writableLocation(StandardPaths.ConfigLocation)) + "/wireplumber/wireplumber.conf.d";
const homePath = homeUrl.toString().replace("file://", "");
const configDir = homePath + "/.config/wireplumber/wireplumber.conf.d";
const configContent = generateWireplumberConfig(); const configContent = generateWireplumberConfig();
const shellCmd = `mkdir -p "${configDir}" && cat > "${wireplumberConfigPath}" << 'EOFCONFIG' const shellCmd = `mkdir -p "${configDir}" && cat > "${wireplumberConfigPath}" << 'EOFCONFIG'
@@ -282,9 +276,7 @@ EOFCONFIG
} }
function loadDeviceAliases() { function loadDeviceAliases() {
const homeUrl = StandardPaths.writableLocation(StandardPaths.HomeLocation); const configPath = wireplumberConfigPath;
const homePath = homeUrl.toString().replace("file://", "");
const configPath = homePath + "/.config/wireplumber/wireplumber.conf.d/51-dms-audio-aliases.conf";
Proc.runCommand("readWireplumberConfig", ["cat", configPath], (output, exitCode) => { Proc.runCommand("readWireplumberConfig", ["cat", configPath], (output, exitCode) => {
if (exitCode !== 0) { if (exitCode !== 0) {
@@ -658,35 +650,39 @@ EOFCONFIG
} }
} }
function playVolumeChangeSound() { function isMediaPlaying() {
if (soundsAvailable && volumeChangeSound && !notificationsAudioMuted) { return MprisController.activePlayer?.isPlaying ?? false;
volumeChangeSound.play();
} }
function playVolumeChangeSound() {
if (!soundsAvailable || !volumeChangeSound || notificationsAudioMuted || isMediaPlaying())
return;
volumeChangeSound.play();
} }
function playPowerPlugSound() { function playPowerPlugSound() {
if (soundsAvailable && powerPlugSound && !notificationsAudioMuted) { if (!soundsAvailable || !powerPlugSound || notificationsAudioMuted || isMediaPlaying())
return;
powerPlugSound.play(); powerPlugSound.play();
} }
}
function playPowerUnplugSound() { function playPowerUnplugSound() {
if (soundsAvailable && powerUnplugSound && !notificationsAudioMuted) { if (!soundsAvailable || !powerUnplugSound || notificationsAudioMuted || isMediaPlaying())
return;
powerUnplugSound.play(); powerUnplugSound.play();
} }
}
function playNormalNotificationSound() { function playNormalNotificationSound() {
if (soundsAvailable && normalNotificationSound && !SessionData.doNotDisturb && !notificationsAudioMuted) { if (!soundsAvailable || !normalNotificationSound || SessionData.doNotDisturb || notificationsAudioMuted || isMediaPlaying())
return;
normalNotificationSound.play(); normalNotificationSound.play();
} }
}
function playCriticalNotificationSound() { function playCriticalNotificationSound() {
if (soundsAvailable && criticalNotificationSound && !SessionData.doNotDisturb && !notificationsAudioMuted) { if (!soundsAvailable || !criticalNotificationSound || SessionData.doNotDisturb || notificationsAudioMuted || isMediaPlaying())
return;
criticalNotificationSound.play(); criticalNotificationSound.play();
} }
}
function playVolumeChangeSoundIfEnabled() { function playVolumeChangeSoundIfEnabled() {
if (SettingsData.soundsEnabled && SettingsData.soundVolumeChanged && !notificationsAudioMuted) { if (SettingsData.soundsEnabled && SettingsData.soundVolumeChanged && !notificationsAudioMuted) {