2

For example, applications like Files or Document Viewer in Ubuntu:

If I want to focus a window like Sublime Text, then wmctrl -a "Sublime" is straightforward, but for Files, the title can be "Desktop" or "Documents" or whatever folder I'm in.

Basically, I'm trying to adapt the directions here: Custom hotkey/shortcut to open/bring to front an app so that they work when there isn't a constant unique string in the title.

3 Answers3

3

You could use xdotool:

xdotool search --all --onlyvisible --class nautilus windowactivate %@

It will saerch for windows in the WM_CLASS "nautilus" and then focuses those windows.

To find out the WM_CLASS of a window use that command:

xprop WM_CLASS

Then click at the desired window. The output would be (in case of nautilus):

WM_CLASS(STRING) = "nautilus", "Nautilus"

The first one is the class the second one the class name. You can use those values with xdotool as above. It doesn't matter what title the window has.

chaos
  • 4,304
1

Not sure it covers your use case, but I made a tool that allows you to pin a specific window with a shortcut and bring it back to the front :

https://hyperkeys.xureilab.com

https://github.com/xurei/hyperkeys

You can choose the shortcut you want. I personally use SHIFT+ALT+[QWER] to pin and ALT+[QWER] to bring to front.

This is an open-source, linux-first tool. A Windows version is also available.

Hope it helps ! I'm looking for feedback, so if you have any question, create an issue ;-)

xurei
  • 101
0

For the archive: https://gist.github.com/psi-4ward/18c3a596d28a3cfa772101af755545df

A script that respect recently used applications

Psi
  • 163
  • 4