Prevent shell.json edits from replacing symlinked configs - #11096
Open
t4t5 wants to merge 1 commit into
Open
Conversation
Preserve symlinked `~/.config/omarchy/shell.json` files when updating bar settings. The config helper now: - Resolves the symlink target before writing. - Stages changes beside the target for an atomic same-filesystem rename. - Preserves the existing file mode, defaulting new configs to 0644. - Supports dangling symlinks without replacing the link. - Cleans up staging files when `jq` fails.
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.
I keep
~/.config/omarchy/shell.jsonsymlinked into my dotfiles repo, which the manual recommends (Stow). Afteromarchy refresh shellthe widgets I had re-added in the repo never showed up: the link had been silently replaced by a detached 0600 copy.The cause is
commit()inomarchy-shell-config, which stages the new JSON in /tmp andmvs it over the config path.mvonto a symlink replaces the link itself. This is reached byomarchy bar defaults|position|transparent,omarchy refresh shell, and the Quattro upgrader. Every other writer already preserves links: the shell's FileView goes through QSaveFile, and #9372 fixes the migrations. This was the last one.Fix
commit()now resolves the path withreadlink -m, stages beside the resolved target, copies the existing mode onto the staging file, and renames onto the target. I kept the rename rather than switching to the write-throughcatused in #9372 because the shell watches this file and reacts to a partial one (#7100). Staging next to the target also makes the rename a real one; /tmp is usually a different filesystem, so the old "atomic" mv was a copy.Behavior changes beyond the link surviving:
mktemp+mv#9326). A new config is 0644..shell.json.XXXXXXinstead of in /tmp; the existing EXIT trap still removes it on failure.Subsumes #9858, which keeps the
mvand so still breaks the link.test/shell.d/shell-config-test.shcovers the plain, symlinked, dangling, and failed-write cases, and fails on the symlink assertion without the fix.