Skip to content

Focus the browser by its desktop entry's window class - #18640

Merged
dhh merged 4 commits into
omacom:quattrofrom
stevederico:fix/18623-browser-wmclass
Nov 20, 2026
Merged

dhh merged 4 commits into
omacom:quattrofrom
stevederico:fix/18623-browser-wmclass

Conversation

@stevederico

@stevederico stevederico commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

fixes #18623

omarchy-launch-browser focuses the browser after opening a URL, but it guessed the window class from the binary name in the desktop entry's Exec=. That misses any browser whose binary is not named after its class. Zen runs /opt/zen-browser-bin/zen-bin with class zen, Vimma runs vimma-open with class vimma-vimma. The || true hid the miss, so the link opened and focus stayed where it was.

Now the script reads StartupWMClass= from the same desktop entry it takes Exec= from and focuses that class (^zen$). If it finds no window, or the entry has no StartupWMClass, it falls back to the old binary name guess. Nothing about how the browser is launched changes.

Tested

  • bash test/shell.d/launch-browser-test.sh passes on current quattro. New cases:
    • a Zen-like entry (Exec=.../zen-bin %u, StartupWMClass=zen) focuses ^zen$
    • the existing chromium entry with no StartupWMClass still focuses ^chromium.*$
  • bash -n bin/omarchy-launch-browser

Not tested against a real Zen or Vimma install.

@greptile-apps

greptile-apps Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

omarchy-launch-browser now prefers the desktop entry’s StartupWMClass when focusing a browser after opening a URL.

  • Browser links focus the class named by the desktop entry.

Reviews (4) · Last reviewed commit: "Match the declared window class as given..." · Reviewed by Greptile

…hing

A desktop entry's StartupWMClass can be stale (a copied or edited override in ~/.local/share/applications) or overridden at launch (a --class flag in the browser's flags file). Focusing only by it then finds no window where the binary-name guess used to, so try the guess after the declared class misses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
Co-Authored-By: muse-wonder via pi, thinking high <noreply@meta.com>
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Nov 17, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks @stevederico. I reproduced the bug and the fix with a real Zen install (zen-browser-bin, whose entry runs /opt/zen-browser-bin/zen-bin with StartupWMClass=zen) on a disposable Omarchy VM. With Zen set as the default browser and its window on workspace 2, I ran omarchy-launch-browser https://example.com/... from workspace 1. On quattro, focus stayed on workspace 1. With this branch, it moved to Zen on workspace 2.

I ran the same check for the other browsers omarchy default browser offers: Chromium, Chrome, Brave, Brave Origin, Edge and Firefox. On every one, the declared class matches the window's real class, and focus followed the link as it already did on quattro. Chrome's entry declares both Google-chrome and google-chrome, and the first one still matches because the focus lookup ignores case.

One fix pushed to your branch (8e84c2e): if the declared class finds no window, the launcher now falls back to the old binary-name guess. Before this, any entry with a StartupWMClass skipped the guess entirely, so a stale or overridden class focused nothing where quattro used to work. I checked this on the VM: a ~/.local/share/applications/chromium.desktop override with StartupWMClass=chromium-stale left focus behind with the branch as it was, and finds the Chromium window with the fallback. launch-browser-test.sh has a case for it (the mock focus helper now records every call and can be told to miss one pattern), and the dotted-class case now also checks that the guess is skipped when the declared class works.

Tests: run on the VM at 8e84c2e. launch-browser-test.sh, default-browser-lookup-test.sh, hyprland-focus-app-test.sh and ./test/cli all pass. Your Zen case fails against quattro's script, and the new fallback case fails against the branch without the fallback.

Second opinion: Codex Medium and muse-wonder (via pi, thinking high) reviewed it over two rounds. In the first round, both found the missing fallback on their own, which is what the pushed commit fixes. They also suggested reading StartupWMClass only from the [Desktop Entry] group and stripping CR and surrounding whitespace. I left that out: with the fallback, a malformed value now ends in the old behaviour, and none of the seven supported browsers' entries has that shape. In the second round, at 8e84c2e, Codex found nothing to fix. muse-wonder pointed out that when the declared class misses, the fallback's prefix can match a sibling browser's window (^brave.*$ matches both brave-browser and brave-origin). quattro uses that same prefix every time, so that's no worse than today. Independence is not guaranteed: the reviewers can read this session's notes.

Overlaps: #12786, #15634, #13240 and #17134 also rewrite this focus line, for other bugs (web app windows, agent browsers, env and flatpak wrappers). Whichever lands first will leave the others to resolve a conflict. When an entry declares a class, the exact match here already avoids web app and chromium-swarm-style windows that share the browser's prefix.

It is now waiting on the maintainer.

omarchybot and others added 2 commits November 18, 2026 14:21
omarchy-hyprland-focus-app matches its pattern as a case-insensitive regex, and a class with a regex character either over-matches harmlessly or fails to the binary-name fallback, so the escaping went. The test keeps the zen case that fails on the base branch.

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

Copy link
Copy Markdown
Collaborator

I merged current quattro into this branch; it was 198 commits behind. I also dropped the regex escaping of the window class (the focus helper matches case-insensitively, and a class with a regex character falls back to the binary-name guess) and trimmed the test to the Zen case. I updated the description to match.

What was checked, on an Omarchy worker, against the merged branch:

  • launch-browser-test.sh passes, and fails against quattro's code.
  • ./test/cli passes, 136 checks.

Claude Opus 5.5 at high effort reviewed the changes as a second opinion; its findings are folded in. Its independence from my review isn't guaranteed. Greptile scores the new head 5/5 with no open findings.

This waits on the maintainer.

@dhh
dhh merged commit 32baee9 into omacom:quattro Nov 20, 2026
3 checks passed
omarchybot added a commit to paulogeyer/omarchy that referenced this pull request Nov 22, 2026
…ommands

Read StartupWMClass from the desktop file selected by the shared Exec parser, so the window-class focus fix from omacom#18640 and wrapped command launching use the same entry. Keep quattro's declared-class lookup and binary-name fallback.

Co-Authored-By: GPT-6 <noreply@openai.com>
@emirb emirb added this to the 4.6.0 milestone Dec 1, 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 ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

omarchy-launch-browser doesn't focus a browser whose Exec name differs from its window class (Zen, Vimma)

4 participants