fix(daemon): apply config written after daemon startup (first-run race)#8
Open
BluePhi09 wants to merge 1 commit into
Open
fix(daemon): apply config written after daemon startup (first-run race)#8BluePhi09 wants to merge 1 commit into
BluePhi09 wants to merge 1 commit into
Conversation
On a fresh home the shell (Ambxst) starts the axctl daemon immediately but writes axctl.toml only moments later. The daemon stat'ed the config at startup and, when missing, skipped BOTH the initial apply AND the fsnotify watcher — so the first config ever written was silently ignored for the whole session. Result: on the very first login the generated compositor config (keybinds, appearance, layer rules) never materialized; everything started working only from the second login on. Fix: - always start the config watcher, even when the file doesn't exist yet (and create its parent directory so it can be watched) - watch parent directories in addition to the files themselves, because fsnotify cannot watch a nonexistent path (and file-level watches break on atomic rename saves) - filter events by path so unrelated files in the same directory (e.g. the generated hyprland.conf/.lua the daemon itself writes there) don't trigger spurious reloads Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On a fresh home directory (new machine, new user, first login ever), the compositor config that axctl generates (
hyprland.conf/hyprland.luawith keybinds, appearance and layer rules) never materializes for the entire first session. Everything only starts working from the second login onward.Concretely, with Ambxst on Hyprland this means: the shell starts and the bar renders, but none of the Ambxst keybinds (launcher, dashboard, clipboard, …) work and none of the appearance settings (gaps, rounding, layer rules) apply until the user logs out and back in.
Root cause
A startup race between the shell and the daemon:
AxctlService.qmlstartsaxctl daemonimmediately (running: trueon theProcess).CompositorTomlWriter.qmlwritesaxctl.tomlonly after that — inComponent.onCompleted, gated on the config loader being done, and through a spawnedbashprocess.runDaemon()inmain.gostats the config path once at startup. When the file is missing it printedNo config file at …, skipping— and skipped both the initial apply and the creation of the fsnotify watcher.So on a fresh home the daemon always wins the race, and the config the shell writes moments later is silently ignored until the next session. (The shell never sends
Config.Applyover IPC on its own; daemon startup and the file watcher are the only apply paths.)Fix
waiting for it to appearinstead ofskipping.isConfigPath) so unrelated files living in the same directory don't trigger reloads. This matters because the daemon itself writes the generatedhyprland.conf/hyprland.luainto that very directory (~/.local/share/ambxst/) on every apply — without the filter, directory watching would cause reload feedback loops. Paths are normalized withfilepath.Cleanon both sides of the comparison.Testing
Verified end-to-end in a NixOS VM running Hyprland 0.55.4 + Ambxst:
-cpointing into a fresh home where neither the config file nor its directory existed → logsNo config file at … yet, waiting for it to appear, directory created, watcher armed.axctl.toml→ picked up immediately:Config changed, reloading…, generatedhyprland.conf+hyprland.luaappeared, compositor reload dispatched. Subsequent daemon self-writes of the generated files into the same directory triggered no further reloads.go test ./...passes.🤖 Generated with Claude Code