Sync XDG text handlers when the default editor changes - #10200
Open
fsousas wants to merge 1 commit into
Open
Conversation
omarchy-default-editor only wrote the Omarchy-internal default state, so a GUI selection (code, cursor, zed, sublime_text) never became the XDG handler for text files: the packaged system mimeapps.list keeps text/plain and the other text MIME types bound to nvim.desktop. Using the Omarchy menu to pick VSCode therefore still opened text files in Neovim from the file manager and launcher. Set the editor as the per-user XDG default for the same text MIME types the packaged system mimeapps.list ships for nvim. For GUI editors whose packaged desktop entry does not declare those types (code, cursor, zed, sublime_text), install a per-user desktop override that adds them so XDG honours the association. Preserve [Added Associations] and unrelated keys. Tests cover the mimeapps rewrite, the desktop override, switching back to a TUI editor, and preservation of the Added Associations section.
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
Picking a GUI editor (e.g. VSCode) as the default under
Setup > Defaults > Editor(oromarchy default editor code) did not actually make it the handler for text files.omarchy-default-editoronly wrote the Omarchy-internal default state (~/.local/state/omarchy/defaults/editor):/usr/share/applications/mimeapps.list, shipped byomarchy-settings) keepstext/plainand the other text MIME types bound tonvim.desktop.omarchy-default-editortouched the XDG defaults, so the file manager / launcher kept opening text files in Neovim even after the user selected VSCode as the default editor in the Omarchy menu.mimeapps.listassociation is ignored by XDG —code.desktoponly declaresapplication/x-code-workspace.The
omarchy default browserandomarchy default terminalcommands already sync their selection to the XDG layer (xdg-settings set default-web-browser/~/.config/xdg-terminals.list); the editor command was the only default that did not.Solution
omarchy-default-editornow applies the selection to the user's XDG state when it sets the editor:[Default Applications]section of~/.config/mimeapps.listso every text MIME type the Omarchy system default binds to nvim maps to the chosen editor's desktop entry. Other keys and sections ([Added Associations], unrelated defaults) are preserved verbatim.~/.local/share/applications/<id>.desktopwith the text MIME types appended toMimeType=, which is what XDG requires for the association to be honoured.code.desktopdefault can't shadow a laternvim.desktopchoice).Terminal editors (nvim, vim, helix, emacs) keep their existing desktop entries and work from a file manager unchanged.
Behavior after this change
Setup > Defaults > Editor> VSCode (oromarchy default editor code): text files opened from the file manager or launcher open in VSCode, not Neovim.$EDITOR(already wired toomarchy-launch-editor).manual/18-development-tools.md) now documents the full behavior.Tests
Extended
test/shell.d/default-apps-test.shwith coverage for:[Added Associations]section when switching./test/shell.d/default-apps-test.shpasses; the affected suite (default-apps-test) is green. The 5 unrelated failures in./test/allare pre-existing on this machine (missingomarchy-pkgscheckout, QML/display environment, executable perms) and reproduce on a clean tree.