Using Alt +Tab normally does what I want; it groups windows from the same application. If I want to switch between windows of one and the same application, I use Alt +`
However, if I have multiple terminal windows open (for example), and I use Alt +Tab to switch to another application, and then switch back to the terminal, another terminal window is in front than the last one.
How do I force it to always return to the same application window, like gnome 3 does?
Ubuntu 14.04 unity.
Best Answer
Below a script that switches through application windows. It remembers the last used (= frontmost) window of all running applications, bypassing other windows of the same application.
The script is based on the same principle as the scripts here, but since the script only runs when a key combination is pressed, the last used window (per application) needs to be stored and read outside the script(-'s memory).
How to use
The script uses
wmctrl
Copy the script below into an empty file, same it as
alternative_switcher.py
Add it to a shortcut key combination: Choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command:
Use it as an alternative switcher with your key combination.
Note
The script switches among "normal" application windows, as defined as: "_NET_WM_WINDOW_TYPE_NORMAL" in the output of the
xprop -id <window_id>
command. That means that dialogue windows will be excluded from the window list, as well asIdle
windows for example, which have pid 0.The script