Is there something similar to quake mode in tilix for Firefox?
I want to switch to any already running instance of firefox (or maybe open a new one if not present already) using a shortcut like F12 or F11.
I do not know of a "native" way to assign a shortcut in order to switch to an existing window. It could be done with a script involving
wmctrl. However, I am using a little tool
jumpapp at https://github.com/mkropat/jumpapp, which uses
wmctrl behind the screen.
wmctrl is not installed by default, so install it using
sudo apt install wmctrl.
Following one-liner will switch to Firefox, or launch it if no window currently is open:
wmctrl -xa Firefox || firefox
In Bash shell, the command separator
|| means: if the first command was not successful, then try the next one. Thus, the first command
wmctrl attempts to activate a window of WM_CLASS
Firefox. Only if no such window is found, which implies Firefox is not running, the command after the separator is launched, i.e., starting the Firefox browser.
To find the WM_CLASS of a window to use in the
wmctrl command, use
x will add a column showing the window class, as in
0x04400003 0 Navigator.Firefox hostname keyboard - Is there a way to bind shortcut keys to switch to already open applications in Ubuntu 18.04 LTS? - Ask Ubuntu - Mozilla Firefox
The third entry,
Navigator.Firefox shows we can use
Firefox as the window class to identify the window.
Using a tool jumpapp
wmctrl directly is not quite complicated, a tool
jumpapp is even more simple in use, and has a few added benefits:
jumpapp is not in the repositories, but can conveniently be installed as a .deb following the instructions on the website:
sudo apt-get install build-essential debhelper pandoc shunit2 git clone https://github.com/mkropat/jumpapp.git cd jumpapp make deb sudo dpkg -i jumpapp*all.deb sudo apt-get install -f # if there were missing dependencies
jumpapp is installed, simply precede the command to launch your application by
jumpapp to launch your application launched if it is not running already, or switch to an existing window. Assign that command to a shortcut key.
You can also edit the "Exec=" line in a
.desktop file, to provide the same functionality to a launcher. As a matter of fact, a command
jumpappify-desktop-entry is included that will do that automatically for a .desktop file you specify.
Launchers in Gnome Shell already behave like this by default, but in other desktops, the app can be used to provide similar "launch or switch-to" functionality to launchers.