fix(theme): stop the update script from stalling wallpaper switches

execAsync resolves only once stdout/stderr reach EOF, and update_script.sh
started dunst with '&' so the daemon inherited AGS's captured pipes. Once
theme switches were serialized behind themeQueue, that pending promise blocked
every later switch, including the one restoreTheme() queues at startup, so
clicking a wallpaper did nothing.

- detach dunst with setsid and redirected stdio in update_script.sh
- run update_script.sh with its fds detached and without awaiting it, so
  user-added commands can never stall the queue
This commit is contained in:
pascalyazid committed 2026-11-27 19:15:34 +01:00
1 parent 58749dcbdc
commit 6347fdbc2a
2 files changed
+22 -9

No files matched your search

+18 -6
View File
@@ -207,13 +207,25 @@ async function applyTheme(wallpaperPath: string) {
// 4. Keep the greetd greeter in sync with the current palette/wallpaper
await exportGreeterTheme()
// 5. Run update script
try {
const agsDir = `${HOME}/.config/ags`
await execAsync([`${agsDir}/update_script.sh`])
} catch (error) {
console.error("Failed to run update script:", error)
// 5. Refresh the rest of the system (dunst, hyprland, ...). Deliberately not
// awaited, so nothing the script does can stall the theme queue.
runUpdateScript()
}
/**
* Run update_script.sh detached from our stdio.
*
* execAsync resolves only once stdout/stderr reach EOF. A daemon started with
* `&` in the script would inherit those pipes and keep the promise pending
* forever, which used to block every queued theme switch after the first one.
*/
function runUpdateScript() {
const script = `${HOME}/.config/ags/update_script.sh`
return execAsync([
"bash",
"-c",
`"${script}" >/dev/null 2>&1 </dev/null`,
]).catch((error) => console.error("Failed to run update script:", error))
}
let themeQueue: Promise<void> = Promise.resolve()
+4 -3
View File
@@ -1,8 +1,9 @@
#!/bin/bash
#Dunst notification daemon
# Dunst notification daemon.
# Detach it from this script's stdio: AGS only resolves execAsync once the
# captured pipes are closed, so an inherited fd here would stall the caller.
killall dunst
dunst &
setsid -f dunst >/dev/null 2>&1 </dev/null
hyprctl reload