How to force activation/focus of new tab when opening file from command line?

Hi,
I’m trying to open a text file from command line, to be opened by default app.
I’m using both next variations:

  1. xdg-open example.txt
  2. gio open example.txt

(for "xdg-mime query default “text/plain”, the value is “org.gnome.TextEditor.desktop”)

The result of command depends on whether the text-editor app is already opened.
If it is not, then it will open and the tab of example.txt will be active.
If is already opened, with other files, then I only see a notification message:
“Text editor, example.txt is ready”, but the text editor is not activated/focused.

I was not sure if this is behavior of the shell or the text editor app, so I changed the default opener of txt files from default Text editor, to Codium.
The result is the same, so I assumed its related only to the shell.
And then changed default opener to Firefox.
In Firefox, it always activates the new tab.
So now I’m bit confused.

Is this behavior, of not focusing/activating, is shell only, or also app depending per it’s implementation (maybe obeying some “rule”?), or mix of both ?

Is there any way to change this behavior, so when opening new file, it will always be activated/focused ?
Maybe there is some flag of or configuration I’m missing ?

I know its possible if I use external extension to list all windows and interact with them via gdbus and force activate, but I’m checking for a simpler solution if exists.

Thanks for any help.
JD.

I use this extension: Grand Theft Focus - GNOME Shell Extensions

I also had this one suggested that does the same thing: Steal my focus window - GNOME Shell Extensions

1 Like

Thanks for your help, it works !

I understand the rational behind this “notification”, but based on number of the downloads of the extension and some other like it, I guess I’m not the only one who finds it confusing/annoying.

I wish the behavior was more clear, and better if could be configurable without external extension.

Thanks again.

1 Like

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.