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