From 8371fa8ef50006c75acc04146ac0df4e7a1cb32a Mon Sep 17 00:00:00 2001 From: bbedward Date: Fri, 4 Sep 2026 11:29:17 -0400 Subject: [PATCH] audio: resolve the sound theme before the login sound plays fixes #3290 port 1.6 (cherry picked from commit 936b42b4e791e00291c099c3ae149b65d6e9ac3a) --- quickshell/Services/AudioService.qml | 47 +++++++++++++++++++--------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/quickshell/Services/AudioService.qml b/quickshell/Services/AudioService.qml index 6e618ade6..5e3ee9df3 100644 --- a/quickshell/Services/AudioService.qml +++ b/quickshell/Services/AudioService.qml @@ -20,6 +20,8 @@ Singleton { readonly property bool soundsAvailable: MultimediaService.available property bool playersRequested: false property bool soundThemeSupported: false + property bool soundThemeResolved: false + property bool loginSoundPending: false property var availableSoundThemes: [] property string currentSoundTheme: "" property var soundFilePaths: ({}) @@ -549,10 +551,12 @@ EOFCONFIG function checkSoundThemeSupport() { Proc.runCommand("checkSoundThemeSupport", ["sh", "-c", GSettings.getCmd("org.gnome.desktop.sound", "theme-name")], (output, exitCode) => { soundThemeSupported = (output || "").trim().length > 0; - if (soundThemeSupported) { - scanSoundThemes(); - getCurrentSoundTheme(); + if (!soundThemeSupported) { + markSoundThemeResolved(); + return; } + scanSoundThemes(); + getCurrentSoundTheme(); }, 0); } @@ -583,16 +587,13 @@ EOFCONFIG function getCurrentSoundTheme() { Proc.runCommand("getCurrentSoundTheme", ["sh", "-c", GSettings.getCmd("org.gnome.desktop.sound", "theme-name")], (output, exitCode) => { - if (output.trim()) { - currentSoundTheme = output.trim(); - log.debug("Current system sound theme:", currentSoundTheme); - if (SettingsData.useSystemSoundTheme) { - discoverSoundFiles(currentSoundTheme); - } - } else { - currentSoundTheme = ""; - log.debug("No system sound theme found"); + currentSoundTheme = output.trim(); + log.debug("Current system sound theme:", currentSoundTheme || "none"); + if (currentSoundTheme && SettingsData.useSystemSoundTheme) { + discoverSoundFiles(currentSoundTheme); + return; } + markSoundThemeResolved(); }, 0); } @@ -614,6 +615,7 @@ EOFCONFIG function discoverSoundFiles(themeName) { if (!themeName) { soundFilePaths = {}; + markSoundThemeResolved(); return; } @@ -670,9 +672,18 @@ EOFCONFIG } } soundFilePaths = paths; + markSoundThemeResolved(); }, 0); } + function markSoundThemeResolved() { + soundThemeResolved = true; + if (!loginSoundPending) + return; + loginSoundPending = false; + playLoginSound(); + } + function getSoundPath(soundEvent) { const soundMap = { "audio-volume-change": "../assets/sounds/freedesktop/audio-volume-change.wav", @@ -708,9 +719,10 @@ EOFCONFIG log.debug("Reloading sounds, useSystemSoundTheme:", SettingsData.useSystemSoundTheme, "currentSoundTheme:", currentSoundTheme); if (SettingsData.useSystemSoundTheme && currentSoundTheme) { discoverSoundFiles(currentSoundTheme); - } else { - soundFilePaths = {}; + return; } + soundFilePaths = {}; + markSoundThemeResolved(); } function isMediaPlaying() { @@ -765,6 +777,11 @@ EOFCONFIG function playLoginSound() { ensurePlayers(); + // playing before the theme paths land swaps the player source mid-playback, which stops it + if (SettingsData.useSystemSoundTheme && !soundThemeResolved) { + loginSoundPending = true; + return; + } if (!soundsAvailable || !loginSound || notificationsAudioMuted || shouldMuteForMedia()) { return; } @@ -1178,5 +1195,7 @@ EOFCONFIG Component.onCompleted: { rebuildTypedNodeLists(); loadDeviceAliases(); + if (SettingsData.soundsEnabled && SettingsData.useSystemSoundTheme) + getCurrentSoundTheme(); } }