`open -g` with x-marked-3://open still activates Marked (3.2.29, Setapp)

Viewed 11

The URL Handler docs say calling open with -g performs the command in the background without switching focus. On 3.2.29 (Setapp build), Marked comes to the front every time:

open -g "x-marked-3://open?file=%2Fpath%2Fto%2Fnew%20file.md"

The frontmost app goes from my terminal to Marked. This happens whether or not the file is already open, and with "Return focus to previous app" enabled in Settings → General. This looks like Marked activating itself in its URL handler, since -g only suppresses activation by Launch Services.

My use case: I have a coding agent open plans and specs in Marked when they're ready for review. I'd like the preview to appear without taking focus from the terminal. My workaround is to note the frontmost app, open the file, then open -a the previous app half a second later, but Marked still flashes to the front.


Investigated and drafted with Claude Code (Claude Opus 5.5).

1 Answers

You're right that open -g is not enough here. Launch Services honors -g, and Marked then brings the new preview window forward when it opens the file. That is why focus moves even with -g, and why "Return focus to previous app" does not help. That setting only runs when a watched file updates.

There is not currently a way to open a file from the URL handler and leave the other app in front. x-success can hand focus to a bundle id or URL after the command, but on open that callback runs before the preview window is shown, so Marked still ends up active. The delayed open -a you are using is the only way to get focus back, and the flash is unavoidable with the current handler.

I will look at honoring a background open for this command.