Shortcut to open/focus terminal window [duplicate]

I am using shortcut Ctrl+Alt+T for opening a new Terminal window. I am using one of the terminal very often (calculator and simple commands) and I want to set up another shortcut (like Ctrl+Alt+R or any other, I don't care) to switch to this specific terminal window (using gnome-terminal in Unity, Ubuntu 12.04).

Is this possible (and how)?


Solution 1:

There is an application called wmctrl, which can help you. You can install wmctrl by command:

# apt-get install wmctrl

You can get list of currently existing windows by wmctrl -l and see titles and names of currently existing windows. Using titles, you can raise a window by:

$ wmctrl -a <string>

To automatize this procedure, you can start specific gnome-terminal with --title parameter to set its window title. Assuming you've run:

$ gnome-terminal --title=testing

You can run:

$ wmctrl -a "testing"

to raise that window, beware of that the string you used to select window should be specific to that window, shouldn't match with any other window's title.

Solution 2:

I've written a small program called jumpapp for exactly this purpose. It lets you create one keyboard shortcut to opens a new terminal the first time you press it, and to switch to the already open window any time you press it after that. As a bonus, if you have multiple terminal windows open, repeatedly pressing the shortcut will cycle through all the terminal windows.

enter image description here

It's easy to install from source, or you can install it from my PPA:

sudo add-apt-repository ppa:mkropat/ppa
sudo apt-get update
sudo apt-get install jumpapp