Skip to content

Sync XDG text handlers when the default editor changes - #10200

Open
fsousas wants to merge 1 commit into
omacom:quattrofrom
fsousas:fix/editor-default-xdg-sync
Open

Sync XDG text handlers when the default editor changes#10200
fsousas wants to merge 1 commit into
omacom:quattrofrom
fsousas:fix/editor-default-xdg-sync

Conversation

@fsousas

@fsousas fsousas commented Sep 4, 2026

Copy link
Copy Markdown

Problem

Picking a GUI editor (e.g. VSCode) as the default under Setup > Defaults > Editor (or omarchy default editor code) did not actually make it the handler for text files. omarchy-default-editor only wrote the Omarchy-internal default state (~/.local/state/omarchy/defaults/editor):

  • The packaged system mimeapps.list (/usr/share/applications/mimeapps.list, shipped by omarchy-settings) keeps text/plain and the other text MIME types bound to nvim.desktop.
  • Nothing in omarchy-default-editor touched 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.
  • GUI editors (VSCode, Cursor, Zed, Sublime Text) also ship desktop entries that do not declare the text/* MIME types, so a plain mimeapps.list association is ignored by XDG — code.desktop only declares application/x-code-workspace.

The omarchy default browser and omarchy default terminal commands 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-editor now applies the selection to the user's XDG state when it sets the editor:

  1. Rewrites the [Default Applications] section of ~/.config/mimeapps.list so 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.
  2. For GUI editors whose packaged desktop entry lacks the text/* types (code, cursor, zed, sublime_text), installs a per-user desktop override at ~/.local/share/applications/<id>.desktop with the text MIME types appended to MimeType=, which is what XDG requires for the association to be honoured.
  3. When switching editor, the new selection replaces the previous one in the defaults (an earlier code.desktop default can't shadow a later nvim.desktop choice).

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 (or omarchy default editor code): text files opened from the file manager or launcher open in VSCode, not Neovim.
  • Switching to Neovim restores Neovim as the text handler.
  • CLI tools continue to honor the selection through $EDITOR (already wired to omarchy-launch-editor).
  • The manual (manual/18-development-tools.md) now documents the full behavior.

Tests

Extended test/shell.d/default-apps-test.sh with coverage for:

  • the mimeapps.list rewrite for the selected GUI editor (code)
  • the per-user desktop override (code.desktop gains the text/plain MIME type)
  • switching back to a TUI editor (nvim) rewriting the XDG handlers
  • preservation of the [Added Associations] section when switching

./test/shell.d/default-apps-test.sh passes; the affected suite (default-apps-test) is green. The 5 unrelated failures in ./test/all are pre-existing on this machine (missing omarchy-pkgs checkout, QML/display environment, executable perms) and reproduce on a clean tree.

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