Keyboard shortcut to focus on (idle) terminal
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 Edit → Profile Preferences, select Title and Command tab and be sure that the field Initial title contain the word "Terminal":
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 Settings → Keyboard, Shortcuts tab, select Custom Shortcut and add a new 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