From 6347fdbc2a5dc63c8d10ed2b58ab97d141501c87 Mon Sep 17 00:00:00 2001 From: pascalyazid Date: Fri, 27 Nov 2026 19:15:34 +0100 Subject: [PATCH] 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 --- theme.ts | 26 +++++++++++++++++++------- update_script.sh | 7 ++++--- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/theme.ts b/theme.ts index 27d23e3..9f5b7ad 100644 --- a/theme.ts +++ b/theme.ts @@ -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 console.error("Failed to run update script:", error)) } let themeQueue: Promise = Promise.resolve() diff --git a/update_script.sh b/update_script.sh index fa1437a..9b33150 100755 --- a/update_script.sh +++ b/update_script.sh @@ -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