Read the default browser once, and recognise one that registered itself - #9431
Open
VykosMolt wants to merge 1 commit into
Open
Read the default browser once, and recognise one that registered itself#9431VykosMolt wants to merge 1 commit into
VykosMolt wants to merge 1 commit into
Conversation
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.
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.
With no arguments
omarchy-default-browseranswers with the short name for the current browser, and every row of Defaults > Browser runs it in itscheckedguard. It ranxdg-settings get default-web-browsertwice: once for thecase, 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, once per row of the menu.The same mismatch is a second, quieter bug. The unmatched arm echoes the raw desktop id, so the menu compares
userapp-Zen-81ROQ3.desktopagainstzenand the Zen row can never show as checked, whichever browser is actually default.A generated entry names the browser in its
Execrather 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 out of the entry rather than guessed from the filename, because the filenames are not reliable: matching*hrom*would claim Chrome for Chromium. Anything still unidentifiable falls back to the raw id, which is what the command answered before.Testing
On this machine, whose default browser is Zen installed through xdg-settings:
The answer on the left is why the Zen row is never checked; the time on the right is paid once per menu row.
default-apps-test.shgains six assertions: the seven packaged ids still read as their own names, a singlexdg-settingscall on the unmatched path, a single call on the packaged path, a generated Zen entry reading aszen, a generated entry resolved without a second call, and an unidentifiable id still reporting itself. The single-call assertion on the unmatched path fails on quattro, where the count is two, and the generated-entry assertion fails there too../test/shell— 217 of 221 files pass, 2898 assertions; the four failures (config-test,runtime-smoke-test,snapper-test,unowned-system-paths-test) fail identically on unmodified quattro on this machine.This comes out of https://github.com/VykosMolt/omarchy-desktop, where I have been running the Quattro shell as a plain Arch session and fixing what turned up.