Skip to content

Route links from every app through the running default browser - #14441

Merged
dhh merged 3 commits into
quattrofrom
link-handoff
Oct 14, 2026
Merged

dhh merged 3 commits into
quattrofrom
link-handoff

Conversation

@dhh

@dhh dhh commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Clicking a link in foot brings up the browser window that got the tab. Clicking one in Signal doesn't: the tab lands in a Chromium window somewhere out of sight.

Why they differ. foot runs xdg-open URL with a Wayland activation token. Chromium forwards the token to the running instance, and Hyprland (focus_on_activate = true) brings forward the window that took the tab. Electron apps (Signal, and others) send links through the desktop portal (org.freedesktop.portal.OpenURI) instead. They pass no activation token, so xdg-desktop-portal runs the default browser's desktop entry without one, and nothing is focused.

Fix. A static, hidden omarchy-browser.desktop runs omarchy-launch-browser %U, which hands the link to the running browser and focuses its window. ~/.config/hyprland-mimeapps.list points x-scheme-handler/http and https at it. GIO (the portal's lookup) and xdg-mime (xdg-open's) read that desktop-specific list before mimeapps.list, so both paths end up there.

The browser itself stays in mimeapps.list, untouched. Nothing is copied or generated, so nothing needs refreshing when the browser package updates or the default changes:

  • omarchy-cmd-default-browser skips omarchy-browser.desktop and returns the browser behind it. Its xdg-settings and xdg-mime fallbacks run with XDG_CURRENT_DESKTOP= so they never return the routing entry, which would launch itself.
  • Omarchy's own xdg-settings set default-web-browser calls also run with XDG_CURRENT_DESKTOP=. Otherwise xdg-settings reads its write back through the desktop-specific list, sees omarchy-browser.desktop, and writes the old value back.
  • A migration installs the entry and creates the list. If a list already exists, it adds the two handlers, unless the user already set an http or https handler there.

Default browser check. With the routing entry in front, browsers think they aren't the default and ask. --no-default-browser-check goes into the shipped Chromium flags and, through a migration, into existing Chromium, Chrome, Edge, Brave and Brave Origin flags files. omarchy-cmd-browser-handoff accepts it as one of Omarchy's own flags. A managed DefaultBrowserSettingEnabled=false policy (omarchy.json, installed wherever Omarchy sets up a Chromium-family policy directory, and by the migration into existing hardened ones) also hides the "Make default" button. That button would otherwise run xdg-settings inside the session and fail on the same read-back. Firefox and Zen get the DontCheckDefaultBrowser policy. On existing installs it is merged into policies.json, keeping anything an administrator added there.

Focus. omarchy-hyprland-focus-app now picks the matching window focused last (focusHistoryID) instead of the first one listed. With several Chromium windows, that is the one Chromium gives the new tab to.

Tests. New browser-link-handoff-test.sh:

  • xdg-mime and GIO route links to the entry.
  • omarchy default browser sets and reads back the browser behind it.
  • The entry is never taken for the browser.
  • The migration installs the entry, adds the handlers once, and keeps a handler the user set.

New default-browser-check-migration-test.sh covers the flag migration (including symlinked flags files), the shipped defaults, and that the migration writes only Omarchy's own policy files as root. browser-policy-dir-test.sh checks that policy setup installs the new policy. browser-handoff-test.sh already copies the shipped flags file, so it covers the allowlist. hyprland-focus-app-test.sh gains a most-recent-window case. The shell suite fails the same 2 files as unchanged quattro (openclaw-cli, passwordless-grant-lifecycle). ./test/cli passes. The migration's root policy writes weren't run here (no passwordless sudo, no Firefox).

Checked live through org.freedesktop.portal.OpenURI over D-Bus, the way Electron calls it:

  • With Chromium closed, the link launched it and focused it.
  • With Chromium on workspace 2 and foot focused on workspace 1, the link went to the running Chromium through the singleton socket (no second launch in the journal), and focus moved to Chromium.
  • With hyprland-mimeapps.list set aside, the same call left focus on foot. That is the original bug.
  • omarchy default browser chromium succeeds inside the session and leaves mimeapps.list naming Chromium.

🤖 Generated with Claude Code

Posted by Claude on behalf of DHH

@greptile-apps

greptile-apps Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new blocking issue was established.

Summary

This PR routes browser links through the default browser’s desktop entry.

  • Links from apps go through the default browser and focus its window.
  • Hyprland focuses the matching browser window used most recently.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[App opens a link] --> B[Default browser desktop ID]
  B --> C[Marked local desktop entry]
  C --> D[omarchy-cmd-browser-open]
  D --> E{Running browser accepts link?}
  E -->|Yes| F[Reuse running browser]
  E -->|No| G[Launch browser through user session]
  F --> H[Focus most recently used matching window]
  G --> H
Loading

Reviews (3) · Last reviewed commit: "Refresh the browser link hand-off entry ..." · Reviewed by Greptile

Comment thread bin/omarchy-refresh-browser-handoff Resolved
Comment thread bin/omarchy-refresh-browser-handoff Resolved
@jandrusk

jandrusk commented Oct 8, 2026

Copy link
Copy Markdown

This fixes a long-standing annoyance. Two small things:

  • omarchy-cmd-browser-open treats the first Exec= token as the browser. For a desktop entry whose Exec starts with a wrapper (env FOO=1 browser %U, flatpak run …), browser_exec becomes env or flatpak. The handoff fails safely, but the focus pattern turns into ^env.*$. Also, omarchy-cmd-default-browser's installed() would see env as the browser's command and treat it as installed. Skipping the copy when the first token isn't a real binary, or isn't the same as TryExec, would avoid both.
  • The copy is a snapshot of the browser's desktop entry. When the browser package updates its entry (new actions, changed flags), the copy stays stale until the next default-browser change or migration. Running omarchy-refresh-browser-handoff on every omarchy update (or from a pacman hook) would keep it in sync.

@dhh

dhh commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

@jandrusk Thanks! Flatpak is out of scope for Omarchy, so wrapper Exec lines aren't something this needs to handle. They fail safely anyway: omarchy-cmd-browser-handoff only takes known browser binaries and otherwise falls back to a normal launch. Your point did lead to a real gap, though. A browser uninstalled with plain pacman -R left the copy looking valid to GLib, because the opener is always on PATH. The copy now carries TryExec of the browser's own binary, so GLib drops it once the browser is gone (da2509a).

On stale copies: omarchy update now refreshes the copy after packages, AUR included (33afa27). I picked that over a pacman hook because a hook runs as root and doesn't know the user's data directory.

Posted by Claude on behalf of DHH

@dhh
dhh force-pushed the link-handoff branch 4 times, most recently from 8f459d6 to 6964bb6 Compare October 14, 2026 00:36
dhh and others added 3 commits October 13, 2026 22:31
A browser hands a new tab to the window that was focused last, so that is
the one to bring forward.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Electron apps open links through the desktop portal, which runs the default
browser's desktop entry without an activation token, so the window that took
the tab stays out of sight. A Hyprland-specific mimeapps list now points http
and https at omarchy-browser.desktop, which opens them through
omarchy-launch-browser to hand them over and focus the window. The browser
itself stays in mimeapps.list, where xdg-settings and the browsers keep it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Links reach the browser through omarchy-browser.desktop, so the browser's own
check finds another handler in front of it and asks to be made the default.
Chromium-family browsers skip that check with --no-default-browser-check,
which the hand-off accepts as one of Omarchy's own flags, and a managed
DefaultBrowserSettingEnabled=false policy hides the button that would rewrite
mimeapps.list behind Omarchy's back. Firefox and Zen get the
DontCheckDefaultBrowser policy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dhh
dhh merged commit 9f49906 into quattro Oct 14, 2026
@dhh
dhh deleted the link-handoff branch October 14, 2026 02:50
ryanrhughes pushed a commit that referenced this pull request Oct 16, 2026
* Focus the matching window used last when several match

A browser hands a new tab to the window that was focused last, so that is
the one to bring forward.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Route links from every app through the running default browser

Electron apps open links through the desktop portal, which runs the default
browser's desktop entry without an activation token, so the window that took
the tab stays out of sight. A Hyprland-specific mimeapps list now points http
and https at omarchy-browser.desktop, which opens them through
omarchy-launch-browser to hand them over and focus the window. The browser
itself stays in mimeapps.list, where xdg-settings and the browsers keep it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Stop browsers asking to be the default behind the link routing

Links reach the browser through omarchy-browser.desktop, so the browser's own
check finds another handler in front of it and asks to be made the default.
Chromium-family browsers skip that check with --no-default-browser-check,
which the hand-off accepts as one of Omarchy's own flags, and a managed
DefaultBrowserSettingEnabled=false policy hides the button that would rewrite
mimeapps.list behind Omarchy's back. Firefox and Zen get the
DontCheckDefaultBrowser policy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 9f49906)
@emirb emirb added this to the 4.0.5 milestone Oct 17, 2026
omarchybot added a commit to JoshJAL/omarchy that referenced this pull request Nov 1, 2026
quattro added DontCheckDefaultBrowser to default/firefox/policies.json so Firefox-based browsers stop asking to be the default behind Omarchy's link routing (omacom#14441). zen-policies.json was copied from the stock file before that, so Zen would still ask. Add the key, and test that Zen's file carries every policy the stock one does so the two cannot drift again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hegjon added a commit to hegjon/omarchy that referenced this pull request Nov 3, 2026
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>
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.

3 participants