Skip to content

Prevent shell.json edits from replacing symlinked configs - #11096

Open
t4t5 wants to merge 1 commit into
omacom:quattrofrom
t4t5:handle-shell-config-symlinks
Open

Prevent shell.json edits from replacing symlinked configs#11096
t4t5 wants to merge 1 commit into
omacom:quattrofrom
t4t5:handle-shell-config-symlinks

Conversation

@t4t5

@t4t5 t4t5 commented Sep 10, 2026

Copy link
Copy Markdown

I keep ~/.config/omarchy/shell.json symlinked into my dotfiles repo, which the manual recommends (Stow). After omarchy refresh shell the 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() in omarchy-shell-config, which stages the new JSON in /tmp and mvs it over the config path. mv onto a symlink replaces the link itself. This is reached by omarchy 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 with readlink -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-through cat used 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:

Subsumes #9858, which keeps the mv and so still breaks the link.

test/shell.d/shell-config-test.sh covers the plain, symlinked, dangling, and failed-write cases, and fails on the symlink assertion without the fix.

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.
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