Skip to content

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

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

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

Conversation

@FizykPSX

Copy link
Copy Markdown
Contributor

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>
@ZackYang

Copy link
Copy Markdown
Contributor

Hi @FizykPSX ,

Apologies for the long silence on this. I was unwell for a while and had to step away from the project, so I did not get to look at your PR until now.

Thank you very much for the contribution, and especially for the thorough write-up. The log trace showing the ["true"] placeholder command at the moment reloadConfig() fires makes the load-order bug very clear, and catching the stale configFile.reload() call in the IPC handler on the side is a nice bonus.

I will review this properly in the next few days and plan to ship it in the next release. I will follow up here once it is merged.

ZackYang added a commit that referenced this pull request Sep 17, 2026
Ported into plugin/ from displaywright-shell-plugin#3 and #2, since the
repository they were opened against is generated from this directory and
would lose them at the next publish.

Omarchy 4.0.3 stopped handing third-party plugins the host's private
__sourceDir (publicPluginManifest deletes it at shell.qml:320, still there
in 4.0.4). Every path this plugin built from it went empty: the service never
read wallpapers.json, the overlay never read monitors.lua, and the launcher
entry was never installed. Reproduced here on 4.0.4-1 before touching
anything -- two displays pinned in the config, `status` reporting theme for
both. The three entry files sit at the plugin root, so the directory now
comes from Qt.resolvedUrl(".") in each, percent-decoded; LauncherEntry takes
it from the service instead of the manifest. Checked offline that the
resolved directory matches through both Qt.createComponent and a Loader, and
with a space in the path.

The startup read is the other half. pluginDir used to arrive after
construction and onPluginDirChanged ran before configReader's command binding
had re-evaluated, so the reader ran its ["true"] placeholder and read nothing
-- pins came back only when the file was next written. pluginDir is a
constant now, but the handler still fires during construction, and a probe
shows the child's binding has not been evaluated at that moment either.
Setting the command at the point the read starts covers both orderings; the
comment says why, rather than the reason that stopped being true.

The reload IPC also called configFile.reload() on a FileView that no longer
exists, so `omarchy-shell displaywright reload` returned an error instead of
ok. It calls reloadConfig() now.

Version 0.7.4, in the package as well as the manifest, as the last bump did.

Co-Authored-By: MACHO MAN <machoxv@protonmail.com>
Co-Authored-By: Pawel Waszkiewicz <fizyk@me.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@ZackYang

Copy link
Copy Markdown
Contributor

Landed — thank you, and for the write-up on #3 as well. This repository is a generated mirror of plugin/ in BlackKingBarOrg/displaywright, so the change went in there rather than through a merge here: displaywright#2, commit 52fa875, with you as co-author, and the mirror has just been republished from it (0.7.4).

Both halves are in: the explicit configReader.command before the read starts, and reload calling reloadConfig(). One detail changed on the way: with #3 making pluginDir a constant, the handler no longer runs because the manifest arrived late — but a qmltestrunner probe shows onPluginDirChanged still fires during construction, before the child's command binding has evaluated, so your fix is still doing real work and the comment now says that.

You're also named in the README's Thanks section.

@ZackYang ZackYang closed this Sep 17, 2026
ZackYang added a commit that referenced this pull request Sep 18, 2026
displaywright#1 reached the same diagnosis as the mirror's #2 independently,
on 4.0.2 with four outputs, and carried the same reload IPC fix. The code
that landed came by the other route, but the finding was theirs as well.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.

2 participants