Indeed, the behavior of the Super+Number keys is to mimic a click on the Dash or Dock, i.e., it brings all windows of the application to the foreground, and if no windows are open, it launches the app.
There are ways to define shortcut keys in a different way, where they only bring one window in the foreground, and where repeatedly pressing the key cycles through the open window.
X-org users (default in Ubuntu 20.04)
The shell script jumpapp allows to set up shortcut keys with the behavior you describe. Pressing the shortcut key will switch to the application if it is running, otherwise launch it. Repeatedly hitting the shortcut key will cycle through all open windows. That script relies on wmctrl
, and therefore unfortunately does not work on Wayland, a newer display driver that is used by default in Ubuntu 20.10 and up.
The script can be installed according to instructions on the jumpapp website over at github.
Default Super+Number keybindings can be disabled by commands, e.g. for Super+1
gsettings set org.gnome.shell.keybindings switch-to-application-1 ['']
That key then becomes available to bind a custom command, using "Settings" - "Keyboard shortcuts", section "Custom Shortcuts". Such command can be for example:
jumpapp gnome-terminal
which would either launch the terminal or launch between open terminal windows.
This approach is disconnected from the dock. If you change the order of icons on the dock, you need to reassign the shortcut keys. However, this approach also allows you to set up any keybinding, e.g. Super+T for the terminal or Super+w for the webbrowser.
Wayland (default in Ubuntu 20.10 and up)
Wayland users can use a Gnome Shell extension, Run or raise by e2rd. Also this extension will allow to cycle through the open windows by repeatedly pressing the key. The extension's home page contains detailled instructions on how to setup keybindings.
This extension can be installed from the Gnome Shell extensions website.