Unity Shortcut Keys – Focus on Idle Terminal


I would like to know, if there is possible to use keyboard shortcut to focus on first idle (non working) terminal window in unity (13.10)? Something like Ctr+Alt+T, but before opening the new instance of terminal, searching for any idle instance?

Best Answer

First set the world "Terminal" to appear in the window title of your gnome-terminal. To do this, when you are in gnome-terminal go to EditProfile Preferences, select Title and Command tab and be sure that the field Initial title contain the word "Terminal":

Terminal - Title and Command

Second, add a new custom keyboard shortcut for the following command:

bash -c "[[ \"$(cat /proc/$(xdotool getwindowpid $(xdotool getwindowfocus))/comm)\" != \"gnome-terminal\" ]] && wmctrl -a Terminal || xdotool key Alt+grave"

To do this, go to System SettingsKeyboard, Shortcuts tab, select Custom Shortcut and add a new custom shortcut:

Add custom shortcut

As you can see, I chose as shortcut F8 key which is working great in this case for me.

Note: wmctrl and xdotool must to be installed in order to use them. If you don't have them installed, you can install them from terminal using:

sudo apt-get install wmctrl xdotool