Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using Unity is there a way to create a single key shortcut to switch to an existing instance of an application? For instance, rather than hitting alt-tab N times to switch to my browser I could simply hit F1, for a terminal I could hit F2.

The run-one solution in another question doesn't work as it launches a new instance. The Launcher itself comes close as it allows me to use Super-[0-9] for pinned applications. This would be sufficient if I could remap the launcher shortcuts to be single keys.
Perhaps there is a dbus message that could be send from a script and the script could be tied to a custom shortcut? A simpler solution would be great too.

share|improve this question
In two-keys case super+A does it . – atenz Jul 23 '12 at 17:44
Have you tried adding your desired action/command key to: "System Settings" > Keyboard > Shortcuts? – Brandon Bertelsen Jul 23 '12 at 17:50
Both of those open a new instance/window rather than switching to the existing one. Your comments have given me the idea to try using xdotool to simulate the presses. – Marc Jul 24 '12 at 16:18

An ugly solution is to use xdotool to simulate the Super-[1-9] keypress. The xdotool command sequence can then be mapped to a custom keyboard shortcut from "System Settings" > Keyboard > Shortcuts". The commands to be run for the shortcuts are


sh -c 'echo "keydown super sleep 0.2 key 1 super" | xdotool -'


sh -c 'echo "keydown super sleep 0.2 key 2 super" | xdotool -'


sh -c 'echo "keydown super sleep 0.2 key 3 super" | xdotool -'
share|improve this answer
This is cool solution thank you. Unfortunately I couldn't manage to simulate a shift+super+key with xdotool in order to force a new instance of an app instead of switching to it. Can you please help me out on this? – aleprovencio Sep 11 '12 at 20:27
This seems to work for me with chrome in the first position. sh -c 'echo "keydown super keydown shift sleep 0.2 key 1 super keyup shift" | xdotool -' @aleprovencio – Marc Sep 14 '12 at 18:54

I use AutoKey to map keys for switching to Terminal. A short demo is here. It's very easy to use.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.