Ubuntu 18.04 (and presumably other versions that use Gnome, such as 17.10 and 18.10) has global keyboard shortcuts for switching among applications based on their location in the dock with Super–0…9:
But if you have multiple windows a given application open, instead of switching to the application, it will display a menu of all the open windows. You have to select one of the windows (using Enter or the mouse) to switch to the application.
Is there a way of having these global shortcuts instead automatically switch to the window of the application that's closest to the foreground?
Best Answer
The Super+0/ ... /9 combination actually triggers the action set for mouse click on application icons in Ubuntu dock. In your case it's set to 'window previews' and so the key combination shows window previews.
If you set another action for mouse click you would see a different behaviour. For example, if you run the following command in Terminal it would just raise the window closest to the foreground as you wish:
(Note that as mentioned above it would also change the behaviour on mouse click on application icons.)
As mentioned by @vanadium in comments below, another alternative is to use the
cycle-windows
option. This option also raises the first window on click (or pressing the hotkey), but if you repeat the click (or the hotkey), other windows of the same app are consecutively raised. To set this option, run