Skip to content

Skip the xprop probe in the default browser fallback - #13830

Open
hegjon wants to merge 5 commits into
omacom:quattrofrom
hegjon:default-browser-without-xdg-settings
Open

hegjon wants to merge 5 commits into
omacom:quattrofrom
hegjon:default-browser-without-xdg-settings

Conversation

@hegjon

@hegjon hegjon commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

When nothing is set in a config dir, omarchy-cmd-default-browser falls back to xdg-settings and xdg-mime, asking with XDG_CURRENT_DESKTOP empty. xdg-utils doesn't know an empty or Hyprland desktop, so it probes for XFCE with xprop -root, twice in xdg-settings and twice more in the xdg-mime it calls. The menu runs this lookup at login to check Defaults > Browser:

Hyprland
└─ omarchy-launch-shell
   └─ quickshell
      └─ bash (menu guard batch, MenuModel.js)
         └─ omarchy-default-browser
            └─ omarchy-cmd-default-browser
               └─ xdg-settings get default-web-browser
                  └─ xprop -root

Both fallback calls now ask as X-Generic, which xdg-utils knows, so they skip the probe. Like the empty desktop, it skips the desktop-specific list, which points at omarchy-browser.desktop. Everything else in the fallback is unchanged: both answers still have to pass installed(), xdg-mime still runs when xdg-settings names a browser that is gone, and the mimeinfo.cache fallback stays.

default-browser-lookup-test.sh now checks that the fallback asks xdg-settings as X-Generic. That check fails without this change.

Measured on a ThinkPad X200 (Core 2 Duo) running Hypoland, a Hyprland fork for OpenGL ES 2.0 GPUs, where I found it:

  • Hypoland starts Xwayland when the first X11 client connects, and there the first xprop started it. This removes one of the two things that start Xwayland at login in an Omarchy session. The other one is fcitx5's X11 addons (xim, xcb). With both gone, Xwayland starts only when an X11 program runs, which saves 150 ms of CPU and about 31 MiB at login.
  • Hyprland starts Xwayland with the compositor, so on stock Hyprland this change only saves the four xprop calls (and the dbus-send calls xdg-utils makes alongside them).

Tests: default-browser-lookup, default-apps, browser-env, launch-browser and menu-guards pass.

🤖 Generated with Claude Code

xdg-settings does not know Hyprland and probes for XFCE with xprop, so the
menu's check of the default browser starts Xwayland at login. Read it with
omarchy-cmd-default-browser, like the browser launchers do.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] No new blocking issue was found in the reviewed changes.

Summary

The browser lookup now asks both fallback commands as X-Generic, avoiding the desktop probe.

  • Browser lookup skips the desktop probe on its fallback path.

Reviews (4) · Last reviewed commit: "Test the X-Generic fallback in the defau..." · Reviewed by Greptile

Comment thread bin/omarchy-default-browser Resolved
Comment thread test/shell.d/default-apps-test.sh Resolved
Comment thread test/shell.d/default-apps-test.sh Resolved
Without a default in a config dir, omarchy-cmd-default-browser asks
xdg-settings, which probes for XFCE with xprop. Ask it as X-Generic, which
takes the same generic path without the probe. The default-apps test now
covers the direct lookup and the fallback, and ignores the caller's
XDG_CONFIG_DIRS.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@sanjyay

sanjyay commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Tested on commit dec0c22 in an isolated Omarchy VM.

Background & Root Cause Verification

  1. Hyprland DE detection in xdg-utils: Under Hyprland (XDG_CURRENT_DESKTOP=Hyprland), xdg-settings's internal detectDE function does not match any recognized desktop environment and falls through to classic fallbacks:
    + xprop -root _DT_SAVE_MODE
    + xprop -root
    Executing xprop against $DISPLAY connects to the X11 display socket, triggering Hyprland to launch Xwayland on demand at login whenever the menu inspects the default browser.
  2. Behavior with omarchy-cmd-default-browser & XDG_CURRENT_DESKTOP=X-Generic:
    • omarchy-default-browser now routes through omarchy-cmd-default-browser, which inspects configured mimeapps.list files directly, resolving the default desktop entry without spawning xdg-settings.
    • In fallback scenarios where no association exists in the config dirs, setting XDG_CURRENT_DESKTOP=X-Generic routes detectDE to DE=generic, completely bypassing the xprop probe calls.

Automated & Runtime Tests

  • test/shell.d/default-apps-test.sh:
    • Verified default browser resolution from mimeapps.list (both supported identifiers and unknown desktop IDs printed as their desktop IDs).
    • Verified fallback invocation logs X-Generic in OMARCHY_TEST_XDG_DESKTOP_LOG without desktop probe calls.
    • All 13 assertions passed cleanly.
  • test/shell.d/browser-env-test.sh & test/shell.d/menu-guards-test.sh:
    • Verified all menu guards and browser environment assertions passed (22/22 passed).
  • Runtime trace:
    • Verified with bash -x omarchy-default-browser that resolving chromium.desktop executes directly from mimeapps.list.
    • Verified with an empty test home that the fallback env -u BROWSER XDG_CURRENT_DESKTOP=X-Generic xdg-settings get default-web-browser avoids invoking xprop.

Clean, direct fix.

If you'd prefer not to receive these independent reviews on your PRs, reply to this comment, and I won't review your future PRs.

@jandrusk

Copy link
Copy Markdown

Nice, and the X-Generic fallback is a neat way to dodge the xprop probe. Two nits: omarchy-default-browser prints an empty line and exits 0 when no default resolves, so maybe return nonzero there. The test also still inherits XDG_DATA_DIRS. Otherwise LGTM.

@jandrusk

jandrusk commented Oct 1, 2026

Copy link
Copy Markdown

Nits from the earlier LGTM still open when you have a minute: (1) omarchy-default-browser printing an empty line and exiting 0 when nothing resolves — nonzero would be kinder to menu guards; (2) the test still inherits XDG_DATA_DIRS. Otherwise still LGTM.

@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 3, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at dec0c22. I found nothing to fix, and the fix does what it says.

Reproduction, on a stock Omarchy worker. I put an xprop shim on PATH and ran omarchy-default-browser under XDG_CURRENT_DESKTOP=Hyprland. On quattro it made 4 xprop calls, and 4 again with this PR's two bin/ changes reverted. At this head it made none. All three trees named the same browser (chromium), both with the worker's own mimeapps.list and with empty config dirs, where the X-Generic fallback answers.

Tests on the worker. default-apps (13 assertions), default-browser-lookup, browser-env and menu-guards pass. ./test/cli (the vscode theme test) and launch-browser-test.sh each have one failure, and both fail the same way on quattro, so neither comes from this change.

Second opinion. Codex Medium reviewed it over two rounds and found nothing that blocks it. It did raise one narrowing, which I reproduced. When no config dir names a default, the fallback now runs as X-Generic, so xdg-mime no longer reads a desktop-specific list in a data dir, such as hyprland-mimeapps.list under ~/.local/share/applications or /usr/share/applications. A stock install has no such file: it ships only the unprefixed /usr/share/applications/mimeapps.list, which is still read. Also, xdg-mime default writes to ~/.config, which the helper reads with the desktop prefix before it falls back. Matching X-Generic:Hyprland would not avoid this, because xdg-utils compares the whole XDG_CURRENT_DESKTOP string and would probe again. Codex also pointed out that omarchy-cmd-default-browser does not resolve vendor-subdirectory desktop IDs. That limitation predates this PR, and the launchers already share it.

Related: #14441 changes other parts of the same two scripts and does not compete with this one.

This now waits on the maintainer.

@omarchybot omarchybot removed ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review labels Oct 14, 2026
quattro now reads the default browser through omarchy-cmd-default-browser on its own, so omarchy-default-browser takes quattro's version. What this branch still adds is the fallback: quattro asks xdg-settings with XDG_CURRENT_DESKTOP empty to keep it off hyprland-mimeapps.list, and xdg-utils answers an empty desktop by probing with dbus-send and xprop before settling on the generic path. X-Generic reaches the same generic path directly, and reads x-generic-mimeapps.list, which nothing writes, so it keeps the list skipped without the probe. The omarchy-browser.desktop guards from quattro stay.

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

Copy link
Copy Markdown
Collaborator

This stopped merging cleanly after #14441 landed on quattro, so I merged quattro into the branch (7f4fa15) rather than rebasing. #14441 already makes omarchy-default-browser read the browser through omarchy-cmd-default-browser, so that file now matches quattro. What this pull request still adds is the fallback asking as X-Generic: quattro asks with XDG_CURRENT_DESKTOP empty to keep xdg-utils off hyprland-mimeapps.list, and an empty value still runs xdg-utils' desktop probe. X-Generic goes straight to the generic path and reads x-generic-mimeapps.list, which nothing writes, so the Hyprland list stays skipped without the probe. The omarchy-browser.desktop guards from quattro are kept.

Checked on an Omarchy ISO worker under Hyprland, with no http default in a config dir so the fallback runs: omarchy-default-browser made 4 xprop and 2 dbus-send calls on quattro and with the X-Generic change reverted, and none on the head, answering chromium each time. With an omarchy-browser.desktop entry in a hyprland-mimeapps.list it still answers the browser. ./test/cli passes, and default-apps, browser-env and menu-guards pass; the new fallback case in default-apps fails with the change reverted.

Codex Medium reviewed the merged head and agreed on the mechanism, the tests and that the merge kept both sides; that is agreement, and its independence is not guaranteed. It noted that in an XFCE session, xdg-utils with an empty desktop would read XFCE's own helper file where X-Generic reads the MIME lists; Omarchy runs Hyprland, so I left that alone.

Nothing is left for you here; it waits on the maintainer.

@omarchybot omarchybot removed ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review labels Oct 25, 2026
omacom#16422 reworked the xdg fallback in omarchy-cmd-default-browser to accept only an installed answer and fall back to mimeinfo.cache. Keep that, and ask both xdg-settings and xdg-mime as X-Generic as this branch does.
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Nov 1, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

This stopped merging cleanly again after #16422 landed on quattro. #16422 changed the xdg fallback in omarchy-cmd-default-browser, so I merged quattro into the branch (5e693ef) rather than rebasing. The merge keeps everything #16422 added: both xdg answers have to pass installed(), xdg-mime still runs when xdg-settings names a browser that is gone, and the mimeinfo.cache fallback and exit 1 are unchanged. Both calls still ask as X-Generic, as this branch does.

Checked on an Omarchy ISO worker under Hyprland, at the merged head, in three cases: no http default in a config dir, a hyprland-mimeapps.list pointing at omarchy-browser.desktop, and a mimeapps.list naming a browser that is not installed. omarchy-default-browser made 4 xprop and 2 dbus-send calls in each case on quattro and with the X-Generic change reverted. On the head it made none. All three trees answered chromium in every case. ./test/cli passes, and so do default-apps, default-browser-lookup, launch-browser, browser-env and menu-guards. The X-Generic case in default-apps fails with the change reverted. CI is green.

Codex Medium and muse-wonder (High) reviewed the merged head and found no defect. Both agreed the merge drops nothing from either side. That is agreement, and their independence is not guaranteed. muse-wonder also pointed out that X-Generic makes xdg-mime read x-generic-mimeapps.list before mimeapps.list. Nothing in Omarchy writes that file, so I left it alone.

@hegjon, two things are out of date since #14441, and both are yours to change if you agree:

After that, the maintainer decides whether to take it. On stock Hyprland it saves only the four xprop calls, because Xwayland is already running there.

The mimeapps.list case in default-apps-test covered what omacom#14441 already
landed, and default-browser-lookup-test covers that lookup. Assert the
X-Generic fallback there instead, where the environment is already isolated,
and leave default-apps-test as it is on quattro.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hegjon hegjon changed the title Read the default browser without xdg-settings Skip the xprop probe in the default browser fallback Nov 3, 2026
@hegjon

hegjon commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, both points are fixed in e6fbd01.

You're right that on stock Hyprland this saves only the xprop calls today, because Hyprland starts Xwayland eagerly. That's an open item in Hyprland itself: src/xwayland/Server.cpp starts the server from an idle callback, next to a // TODO: lazy mode comment. It would be useful to port the lazy mode from Hypoland to Hyprland once there are no calls to X11. This probe is one of the two clients at login that I know of. The other is fcitx5's X11 addons (xim, xcb).

With lazy start, Xwayland would stay off until an X11 program actually runs. On my X200 with Hypoland, that saves about 150 ms of CPU and 31 MiB at login. On this machine's Hyprland, Xwayland is using 69 MiB. So this PR is a small cleanup on its own, but it's also groundwork for that change.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Nov 4, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

@hegjon, e6fbd01 makes both changes from the last round. The description now covers only the X-Generic fallback. default-apps-test.sh matches quattro again. The X-Generic check now lives in default-browser-lookup-test.sh. The change to bin/omarchy-cmd-default-browser is the same as at 5e693ef, which was reproduced and tested on an Omarchy ISO worker on November 1. No commit on quattro since then touches these files, and the branch still merges cleanly. CI is green. I read the new test commit but did not run it again: the assertion at default-browser-lookup-test.sh:70 gets unset instead of unset X-Generic with the change reverted, so it guards the xdg-settings call.

Codex Medium and muse-wonder (High) reviewed this head and found no defect. That is agreement, and their independence is not guaranteed. Both noticed one thing I confirmed: nothing tests the X-Generic passed to xdg-mime on line 69, because the fallback case returns on the xdg-settings answer first. Reverting only that line would still pass. That doesn't block anything. Add a check if you want one.

The classification is unsettled at this head. I classified it as a bug, an unneeded probe in the fallback. Codex Medium classified it as an enhancement: the description now presents it as saving work at login, and as groundwork for a lazy Xwayland start. Both readings are reasonable, so it carries no verified or ready label for now. It is waiting on the maintainer, and nothing more is needed from you.

@omarchybot omarchybot removed the bug Something isn't working label Nov 17, 2026
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.

4 participants