Skip to content

Load wallpapers.json at startup, not only when it is next written - #2

Open
FizykPSX wants to merge 2 commits into
BlackKingBarOrg:mainfrom
FizykPSX:fix-startup-config-read
Open

Load wallpapers.json at startup, not only when it is next written#2
FizykPSX wants to merge 2 commits into
BlackKingBarOrg:mainfrom
FizykPSX:fix-startup-config-read

Conversation

@FizykPSX

Copy link
Copy Markdown

What happens

Pinned wallpapers survive a write to wallpapers.json but not a shell restart. After omarchy restart shell, every pinned display goes back to the theme background, while the config file is still on disk and unchanged.

omarchy-shell displaywright status right after a restart:

DP-1	theme	-	-
DP-2	theme	-	-

Touching the file (touch ~/.config/displaywright/wallpapers.json) restores both displays immediately, which is what made this look like a config problem rather than a load-order one.

Why

reloadConfig() is called from onPluginDirChanged, since pluginDir only becomes known once the shell injects the manifest into the constructed service. That handler runs before the command binding on configReader has been re-evaluated, so the Process starts with the ["true"] placeholder it holds while pluginDir is empty. true writes nothing, StdioCollector hands parseConfig an empty string, and monitorSources stays empty — no warning anywhere, because an empty config is a legitimate state.

The inotify watcher is unaffected, so the next write to the file loads it correctly. That is why picking a wallpaper works and only a restart shows the bug.

Logging the state at the moment the read is started:

displaywright: reloadConfig pluginDir= cmd=["true"]
displaywright: pluginDirChanged=/home/pawel/.config/omarchy/plugins/ai.bkblab.displaywright
displaywright: reloadConfig pluginDir=/home/…/ai.bkblab.displaywright cmd=["true"]
displaywright: parseConfig len=0

The change

First commit sets configReader.command explicitly in reloadConfig(), so the read is against configPath regardless of which binding pass has run.

Second commit is a separate bug found next to it: the displaywright IPC reload() still calls configFile.reload(), the FileView that read-config.sh replaced. The call throws, so omarchy-shell displaywright reload returns an error instead of ok. pick-wallpaper.sh calls it to save the watch latency and ignores the failure, so nothing visibly broke — but the IPC target is documented and does not work.

Testing

  • node --test tests/*.mjs — 89 pass, 0 fail
  • Live on Omarchy 4.0.1-1, two displays, both pinned: three consecutive omarchy restart shell runs, each followed by omarchy-shell displaywright status showing pinned for both outputs. Before the change the same loop reported theme for both every time.
  • omarchy-shell displaywright reload returns ok.
  • hyprctl layers still shows the displaywright surface above omarchy-background on both outputs.

🤖 Generated with Claude Code

FizykPSX and others added 2 commits August 30, 2026 22:00
The service starts its config reader from onPluginDirChanged, because
pluginDir is only known once the shell has injected the manifest. That
handler runs before the Process's own command binding has been
re-evaluated, so the reader started as ["true"]: it collected nothing,
parseConfig ran against an empty string, and every output was left to
omarchy.background.

Nothing said so. The inotify watcher picked the file up on the next
write, which made pinning a wallpaper work and made it look like the
config was being honoured -- until the shell was restarted, when every
pinned display quietly went back to the theme background.

Set the command explicitly at the point the read is started, so it is
against configPath rather than against whichever binding pass happened
to have run.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The handler still called configFile.reload(), the FileView that bounding
the config read removed. The call throws, so `omarchy-shell displaywright
reload` returned an error rather than "ok", and pick-wallpaper.sh -- which
calls it to save the watch latency, and ignores the failure -- was left
waiting on inotify for a wallpaper it had just written.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@FizykPSX
FizykPSX force-pushed the fix-startup-config-read branch from c88e6e1 to aebe1aa Compare August 30, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant