Skip to content

Only follow an opened link when an argument is a URL - #7494

Open
meirdick wants to merge 1 commit into
omacom:quattrofrom
meirdick:fix-browser-flag-treated-as-url
Open

meirdick wants to merge 1 commit into
omacom:quattrofrom
meirdick:fix-browser-flag-treated-as-url

Conversation

@meirdick

@meirdick meirdick commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

What this script does

When something opens a link, it runs omarchy-launch-browser <url>. Chromium does not make a new window for that link. It adds a tab to a window you already have open, and that window can be on another workspace. So you click a link and nothing seems to happen.

To fix that, the script moves you to the browser window whenever it is given a link. When it is given no link, it opens a new window and leaves you where you are.

What is broken

The script has to tell a link from an option. It does that by taking the first thing you passed it that is not --private:

for argument in "$@"; do
  if [[ $argument != "--private" ]]; then
    url=$argument
    break
  fi
done

Options are not links, but every option other than --private passes that test. So the script thinks you gave it a link, and moves you to a browser window on some other workspace. Your new window then opens over there.

You see this if a keybinding passes an option, like picking a Chromium profile:

o.bind("SUPER + SHIFT + RETURN", "Browser", "omarchy-launch-browser --profile-directory='Profile 1'")

Press it on workspace 3, land on workspace 4. Same with --new-window, --incognito and --ozone-platform=....

Default bindings pass nothing or --private, so a stock install is not affected.

The fix

Links do not start with a dash. Options do. So only count something as a link if it does not start with a dash:

if [[ $argument != -* ]]; then

--private starts with a dash, so it is covered and the special case goes away.

Testing

  • bash test/shell.d/launch-browser-test.sh — new case passes an option and checks that nothing gets focused. It fails on the current script.
  • ./test/all — bar-icon-geometry-test.sh and snapper-test.sh fail before and after, from a local node that rejects -G.

The launcher took its first argument that was not --private as the URL,
so any other browser flag counted as one and triggered the focus step.
A binding that pins a Chromium profile with --profile-directory then
jumped to whatever workspace already held a browser window, and the new
window opened there instead of on the current workspace.

Treat an argument as a URL only when it does not start with a dash.
@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 Sep 27, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at e428163 by Claude Opus 5.5, with a second opinion from Codex Medium. Nothing found that needs changing.

Reproduced on a disposable Omarchy worker. I wrote a separate reproduction that stubs the browser and the focus helper. It launches with no arguments, with --private, with four options alone (--new-window, --profile-directory=Profile 1, --incognito, --ozone-platform=wayland), with a URL alone, and with each option followed by a URL. On quattro (f814639), all four option-only launches follow focus to the browser window. On this head, and on this head merged into current quattro, none of them do, and every launch with a URL still follows. Reverting the one-line change brings the bug back. Your new case in launch-browser-test.sh also fails on the revert and passes with the fix.

Suite. ./test/cli and the browser-related shell tests ran on the merge with quattro. Two tests fail there, and both fail the same way on quattro alone, so neither comes from this change:

  • vscode generated theme references current theme file in ./test/cli.
  • launch-browser-test.sh, because the test does not put the repository's bin/ on PATH, so omarchy-cmd-default-browser is missing on a machine without Omarchy's commands installed. With bin/ on PATH, it passes on both trees, including your new case.

Second opinion. Codex Medium agreed the change is proportionate and that no stock caller passes an option; independence is not guaranteed. It raised one case that newly skips focus, --new-window "" <url>, where an empty argument stops the scan early. I left it alone because no caller produces it. --profile-directory "Profile 1", with the value as a separate argument, still follows focus, as before; Chromium only reads option values written with =, so it would open "Profile 1" as a page anyway.

Related. #13240 and #11728 rewrite the same argument loop and keep the "first argument that is not --private is the URL" rule, so whichever lands second will need this check carried into it. #10802 goes the other way and rejects every option except --private.

This now waits on the maintainer.

@omarchybot omarchybot added ready Good to merge and removed ready Good to merge labels Sep 28, 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.

2 participants