Hi, all! I’m configuring my terminal-based text editor to open hyperlinks, which works via xdg-open
, but it does not bring the web browser window to focus. I’m running Plasma 6.2.5 Wayland and Firefox browser. I know this is related to a Wayland protocol (XDG activation protocol | Wayland Explorer - ?) but I’m not sure how this can help me fix the issue. Cheers!
I am not sure you can do much here.
Essentially you are running into the window manager’s “focus stealing prevention” which tries to block windows from “stealing” the focus from the one that currently has it.
The activation protocol enabled applications to let the window manager know that they are OK with the focus transfer.
For example if you click a link in an application it can tell the launcher that it agrees if the link handler gets the focus instead.
I.e. focus is “willingly given” not “stolen”.
In order to do that the application needs to pass its own window identifier to the launcher which then passes it on to the other application which then can ask the window manager to get the focus which then verifies that the other window actually has the focus (and can thus agree to pass it on).
A console program like xdg-open would need to somehow get the window identifier of the terminal window it is running in.
Terminal windows, however, usually don’t expose that information.
I guess the best you can do is to try lowering your focus stealing prevention level (System Settings → Window Behavior)
I don’t have a solution personally, just to add in - I use Newsboat for RSS reading, and have its external browser config listing set to xdg-open %u
.
When Firefox is my default browser, opening a link from Newsboat opens it without the existing Firefox window becoming active. When Vivaldi is my default, on the other hand, the Vivaldi window is put into focus.
Maybe that’s due to native Wayland (Firefox) vs. XWayland (Vivaldi) behavior differences?
If your terminal app is Konsole, it sounds like you’re running into 442265 – Opening an app from konsole has no activation environment set. It’s a known issue and just needs someone to fix it. Every other terminal app will need a similar fix.