The wmctrl package offers access and manipulation of application windows and would do what you want. Install this little package first:
sudo apt-get install wmctrl
Here is the man page for wmctrl:
http://manpages.ubuntu.com/manpages/precise/en/man1/wmctrl.1.html
When you look at the command line switches, you will see that -a will raise and focus a window. In order to know which window to focus, make sure you have a Chromium window open, and then run
wmctrl -l
This will give you a list of all open windows and their titles. Chromium will most likely always have "Chromium" in the end of it's window title, so you can use that.
With this information at hand, you can construct your command for the shortcut. Open the Keyboard preferences, go to Shortcuts, click on Custom Shortcuts, click the + sign and enter:
Name: Focus Chromium Shortcut
Command: wmctrl -a 'Chromium'
I am using Unity and just tried this with Google Chrome, it did the trick. It should work in Gnome-Shell as well.
Pretty cool idea :)
DrTebi
After an hour of googling and trying, I've found a workaround to this weird problem. Install and run CompizConfig Settings Manager
:
sudo apt-get install ccsm
ccsm
Click Commands
in General
category. Ensure the module is activated. Add your custom command on the first tab and set a shortcut on the second one. I set the same command (shutter
with options) and the same key (Print
) as I'd set before in "regular" system settings. Now the command began to be run instantly.
Best Answer
Unlock Widgets.
Right-click in launcher and click Edit Applications...
Find the app you want to assign a shortcut
For example: Click on System, and click on Konsole. Click on Advanced Tab. At the bottom you can see Current shortcut key, click on the button and enter the shortcut.