Skip to content

Read the default browser once, and recognise one that registered itself - #9431

Open
VykosMolt wants to merge 7 commits into
omacom:quattrofrom
VykosMolt:fix/default-browser-read
Open

VykosMolt wants to merge 7 commits into
omacom:quattrofrom
VykosMolt:fix/default-browser-read

Conversation

@VykosMolt

@VykosMolt VykosMolt commented Aug 31, 2026 •

Copy link
Copy Markdown

Current Quattro already reads the default browser once through omarchy-cmd-default-browser. This PR now adds recognition of generated desktop IDs through their Exec fields, using the normal XDG data directory defaults and quoted paths. A missing default returns quietly, without trying to read the applications directory as a file.

Exec arguments are read as data, without evaluation or execution. Direct programs, env assignments/options and supported Flatpak browser IDs map to the existing menu names; unknown entries retain their desktop ID. The fixtures isolate XDG_DATA_HOME/XDG_DATA_DIRS from the runner's environment.

Wrapper parsing identifies the browser for menu readback. Browser and web-app launchers do not consume this getter; recognizing a wrapped entry does not establish that those launchers execute its complete argument list. The env -- assignment form currently falls back to the raw desktop ID, matching upstream behavior. The maintainer still needs to decide whether wrapper recognition belongs in this fix or a separate change.

Fresh validation of head 9bb89b6 merged with Quattro 84cfb93 passes 23 default-app checks, 26 menu-guard checks and 125 CLI checks. Cases include generated IDs, a missing default, system paths, spaces, env and Flatpak wrappers, literal command substitutions, unrelated wrappers and single-read behavior.

With no arguments omarchy-default-browser answers with the short name for the
current browser, and every row of Defaults > Browser runs it in its checked
guard. It ran `xdg-settings get default-web-browser` twice: once for the case,
and again in the unmatched arm to echo the raw value.

The unmatched arm is not the rare one. A browser that registers itself through
xdg-settings rather than shipping a packaged desktop entry gets a generated id:
Zen installs `userapp-Zen-81ROQ3.desktop`, which matches none of the seven cases.
So the common path was the one paying twice, and on this machine that is 83ms
against 42ms for asking once, per row of the menu.

The same mismatch was a second, quieter bug. The unmatched arm echoed the raw
desktop id, so the menu compared `userapp-Zen-81ROQ3.desktop` against `zen` and
the Zen row could never show as checked, no matter which browser was actually
default.

A generated entry names the browser in its Exec rather than in its filename, so
the unmatched arm now opens the entry and maps the program it runs back to the
name this command answers with. That is read from the entry rather than guessed
from the filename, because the filenames are not reliable: matching `*hrom*`
would claim Chrome for Chromium. Anything that still cannot be identified falls
back to the raw id, which is what the command answered before.

Tests cover the seven packaged ids still reading as themselves, a single
xdg-settings call on both the matched and the unmatched path, a generated Zen
entry reading as `zen`, and an unidentifiable id still reporting itself. The
single-call assertion on the unmatched path fails on quattro, at two.
@omarchybot omarchybot added the bug Something isn't working label Sep 27, 2026
On quattro the menu batches its guards and runs omarchy-default-browser once per evaluation (GUARD_READERS in shell/plugins/menu/MenuModel.js), so the per-row cost the comment described no longer exists. What remains is the single read, which the code already shows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 1, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed and reproduced on a worker built from the Omarchy ISO. The bug is real and this fixes it.

Reproduction. I registered Zen the way Firefox-based browsers make themselves the default, through GIO's create_from_commandline and set_as_default_for_type. GIO wrote ~/.local/share/applications/userapp-Zen-ZDN0V3.desktop with Exec=<path>/zen %u and pointed x-scheme-handler/http at it. On quattro (c05d901), omarchy-default-browser prints userapp-Zen-ZDN0V3.desktop, so the Zen row in Defaults > Browser can never be checked. This head prints zen, and so does this branch merged with current quattro. With the change to bin/omarchy-default-browser reverted, it prints the raw ID again and the new single-read test fails.

Tests on the worker. default-apps-test.sh (17/17) and menu-guards-test.sh pass on the head, and default-apps-test.sh also passes merged with quattro. ./test/cli passes. In ./test/shell, 219 of 221 files pass. The two that fail, ascii-test.sh ("Hi is 18 columns wide") and branding-about-animation-test.sh, fail the same way at this branch's merge-base and on quattro with this merged in, so this change didn't cause them.

Pushed to your branch. 2b1951e removes the five-line comment above the xdg-settings read. It said the menu paid for the second call once per row, but quattro now batches the menu's guards and runs omarchy-default-browser once per evaluation (GUARD_READERS in shell/plugins/menu/MenuModel.js). The code is unchanged.

Related. #13830 also edits the no-argument path of bin/omarchy-default-browser and default-apps-test.sh: it reads the default from mimeapps.list through omarchy-cmd-default-browser instead of xdg-settings. The two don't fix the same bug, because a generated ID is still in mimeapps.list after #13830, but they will conflict. Whichever lands second needs a rebase. #8903 (a default outside the seven known browsers, such as LibreWolf) is not fixed by this change.

Second opinion. None. The configured reviewer was not run because today's review budget was spent. This rests on one model's review (Claude Opus 5.5), plus the reproduction above.

Next. This waits on the maintainer. It also needs a second-opinion review at this head before it can be marked ready.

@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with no outstanding findings.

Summary

The PR reads the default browser once and recognizes generated desktop entries without running their Exec contents.

  • Generated browser entries now resolve to their browser names.

Reviews (4) · Last reviewed commit: "Compare the xdg-settings call count with..." · Reviewed by Greptile

Comment thread bin/omarchy-default-browser Resolved
Comment thread bin/omarchy-default-browser Resolved
Comment thread test/shell.d/default-apps-test.sh Resolved
@greptile-apps

greptile-apps Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff

These findings could not be posted inline.

  • P1 Security Code-owner assignment removed .github/CODEOWNERS:2 ▶

    Deleting this file removes the catch-all assignment to @dhh and @ryanrhughes. If the protected branch requires code-owner approval, subsequent changes will no longer have designated owners whose sign-off that requirement can enforce. Restore an ownership rule before merging.

    How this was verified: The deleted file assigned * to those owners, and no replacement CODEOWNERS file is present.

@omarchybot omarchybot removed verified Omarchy Triage has verified that this issue is ready for final review bug Something isn't working labels Oct 8, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Looked at the new head, 10c46a1. It merges current quattro into the branch and adds two things in answer to Greptile's review. First, it reads Exec lines with a tokenizer that sees through env wrappers, quoted paths and flatpak run. Second, it searches /usr/local/share and /usr/share when XDG_DATA_DIRS is unset.

Classification is unsettled. Two models classified this separately and disagreed. I (Claude Opus 5.5) read it as a bug fix. Codex Medium read it as an enhancement. Both readings have something to them. The generated Zen entry leaving Defaults > Browser unchecked is a bug on quattro, and it was reproduced on a worker at the earlier head, 2b1951e. Recognising env-wrapped, quoted-path and Flatpak entries is new behaviour that no report asked for. Because of the disagreement, the bug label has come off, and this head has not been run on a worker or given a second-opinion code review. What follows was read at 10c46a1, not run.

The tokenizer goes further than the rest of Omarchy's browser handling. omarchy-launch-browser (line 7), omarchy-launch-webapp (line 13) and omarchy-cmd-default-browser (line 22) all take only the first word of Exec. For a default entry like env MOZ_ENABLE_WAYLAND=1 firefox %u or flatpak run … org.mozilla.firefox, this change would tick Firefox in the menu while those launchers run env or flatpak as the browser. A change sized to the Zen bug is roughly what 2b1951e did: read the first word of Exec, as those three commands already do, plus the XDG_DATA_DIRS fallback. That fallback is a good fix and matches omarchy-cmd-default-browser exactly. Supporting wrapped entries would need the launchers to follow too, so it would be better as its own pull request.

Greptile's CODEOWNERS finding does not apply to this pull request. .github/CODEOWNERS was removed on quattro itself in 8369601 ("Remove CODEOWNERS"). Against current quattro (merge base 50d687a), this pull request changes two files: bin/omarchy-default-browser and test/shell.d/default-apps-test.sh. GitHub's file list for it still compares against an older base (5b91db5, from 8 September), which is why it shows hundreds of files and Greptile's summary describes unrelated agent-account scripts.

Related. #13830 and #14441 both edit bin/omarchy-default-browser, so whichever lands second needs reconciling. #14441 also rewrites a system default browser's copied Exec to start with omarchy-cmd-browser-open, which this tokenizer does not recognise.

Next. This waits on the maintainer to decide whether it is a fix or a feature, and whether the wrapped-entry handling belongs here.

@VykosMolt

Copy link
Copy Markdown
Author

On the scope concern: the getter identifies the browser for menu readback. The launchers do not consume it and remain unchanged. Independent captured-argv checks confirmed their pre-existing env/Flatpak argument loss; this PR does not establish wrapped launcher execution. Direct generated Zen launching remains unchanged, including native verification.

The description now states that boundary. Whether wrapper recognition belongs in this PR, and its bug/enhancement classification, remain maintainer decisions.

… tests

Omarchy's style asks for (( )) rather than -eq inside [[ ]] for numeric tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 13, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Looked at the new head. This time two models classified it separately and agreed it is a bug fix: I (Claude Opus 5.5) and Codex Medium. It is labelled bug and verified.

Reproduction. I ran this on a worker built from the Omarchy ISO. I registered a stand-in Zen through GIO's create_from_commandline and set_as_default_for_type, and GIO wrote userapp-Zen-OUHTW3.desktop. On quattro (a06ec13), omarchy-default-browser prints userapp-Zen-OUHTW3.desktop. This branch, and this branch merged with quattro, print zen. With bin/omarchy-default-browser reverted to quattro's copy, it prints the raw ID again, and the new single-read test in default-apps-test.sh fails.

Tests on the worker. These ran merged with current quattro. default-apps-test.sh passes 22/22, and ./test/cli passes. In ./test/shell, 382 of 393 files pass. The 11 that fail also fail on unchanged quattro, so this change didn't cause them: ascii, background-instant-reload, background-intro-clone, branding-about-animation, hyprland-startup-cursor-cold, launch-browser, menu-guards, remote-session-service, runtime-smoke, screenshot-sanity and webapp-install.

Pushed to your branch. f6873b1 changes the three new call-count checks from [[ $(wc -l …) -eq 1 ]] to (( $(wc -l …) == 1 )), because Omarchy's AGENTS.md asks for (( )) in numeric tests. Behaviour is unchanged, and default-apps-test.sh still passes 22/22.

Second opinion. Codex Medium reviewed it. It found no code that runs anything from the desktop file. It found one case the tokenizer misses: Exec=env -- MOZ_ENABLE_WAYLAND=1 firefox %u. After --, MOZ_ENABLE_WAYLAND=1 is taken for the program, so the entry falls back to its raw ID. That is the same answer quattro gives, so nothing gets worse. I rejected some of its other findings:

  • Contrived Flatpak argument orders that no exported entry produces.
  • Unbound-variable errors that only happen under set -u, which this script doesn't set.
  • An Exec read from a [Desktop Action] section, which only happens when the main section has none.

Scope. Both reviews read the bug's size the same way. A fix the size of the Zen bug finds the entry and maps the first word of its Exec. That is how omarchy-launch-browser, omarchy-launch-webapp and omarchy-cmd-default-browser already read it. The env and Flatpak tokenizer, about 70 lines, is the rest. The missed env -- case shows what it costs to maintain. Because of this scope question, it isn't marked ready.

Next. This waits on the maintainer to decide whether the wrapper recognition belongs here or should be split into its own pull request.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Oct 14, 2026
omarchybot and others added 2 commits October 14, 2026 10:05
quattro now reads the default once through omarchy-cmd-default-browser, which skips omarchy-browser.desktop; the generated-entry resolver now takes its answer instead of a second xdg-settings read of its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An empty id makes the resolver's path the applications directory, which passes -r, so sed read it and printed "Is a directory" to stderr.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 14, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

#14441 landed on quattro and changed the same lines in bin/omarchy-default-browser, so this branch stopped merging. I merged quattro into it and fixed one small defect. It is verified again at 9bb89b6.

The merge, c81f3aa. quattro now reads the default once, through omarchy-cmd-default-browser, which also skips omarchy-browser.desktop. So the single read this pull request set out to add is already on quattro. The merge keeps quattro's read and hands its answer to this branch's resolver in the *) arm. Everything else is quattro's, including the XDG_CURRENT_DESKTOP= on xdg-settings set. The generated-entry fix is still needed: on quattro, a browser registered under a generated ID still prints the raw ID.

Pushed, 9bb89b6. With no default browser set, the resolver got an empty ID. Its path was then the applications directory itself, which passes [[ -r ]], so sed printed read error on …/applications/: Is a directory to stderr. It now checks [[ -f $entry && -r $entry ]]. I also added a test to default-apps-test.sh: with no default, the getter prints nothing and writes nothing to stderr. Codex Medium found this defect.

Reproduction. On a worker built from the Omarchy ISO, I registered a stand-in Zen through GIO's create_from_commandline and set_as_default_for_type, which wrote userapp-Zen-3ZGYW3.desktop. On quattro (7655773), omarchy-default-browser prints userapp-Zen-3ZGYW3.desktop. At 9bb89b6 it prints zen. With bin/omarchy-default-browser reverted to quattro's copy, it prints the raw ID again and the generated-ID test fails.

Tests on the worker, at the head. default-apps-test.sh passes 23/23, and the new test fails with the fix reverted. menu-guards-test.sh and ./test/cli pass. In ./test/shell, 7 files fail that also fail on unchanged quattro: ascii, background-instant-reload, background-intro-clone, branding-about-animation, hyprland-startup-cursor-cold, launch-browser and screenshot-sanity. Two more, background-intro-lifecycle and launch-shell, failed once in the full run. Both passed when run again at this head, and neither reads the default browser.

Second opinion. Codex Medium reviewed it in two rounds. In the first round it found the conflict resolution correct, and it found the empty-ID defect above. It also raised the env -- MOZ_ENABLE_WAYLAND=1 firefox %u case again: that entry still falls back to its raw ID, which is what quattro prints, so nothing gets worse. In the second round it found the fix clean. It reached the same view of scope as I (Claude Opus 5.5) did, and it may have seen my earlier reasoning, so the two views are not guaranteed to be independent. The Zen bug needs the entry looked up and the first word of its Exec mapped. That is how omarchy-cmd-default-browser and the launchers already read it. The env and Flatpak tokenizer is beyond that.

Related. #13830 still edits the same no-argument path and the same test file, so it will need reconciling with whichever lands first.

Next. It is not marked ready, because of the scope question. This waits on the maintainer to decide whether the wrapper recognition belongs here or in its own pull request.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants