I know the easy way using the unity but is there a way to make a shortcut for chrome for example using the terminal.
1 Answer
One way of doing it is to use xbindkeys
:
Install
xbindkeys
sudo apt-get install xbindkeys
Create the default settings file:
xbindkeys --defaults > ~/.xbindkeysrc
Add the relevant lines to
~/.xbindkeysrc
:printf '"google-chrome"\nControl+Shift+Mod2 + c\n' >> .xbindkeysrc
The keycodes above make Crtl Shift C launch
google-chrome
.You might need to get the right keycodes for your keys. Run
xbindkeys -k
and press your desired shortcut. That will print the relevant key sequence.Run
xbindkeys
. To make this permanent, add a line containingxbindkeys
to your~/.Xsession
:echo xbindkeys >> ~/.Xsession
Now, once you have all that set up, and xbindkeys
is running automatically every time you log in (because of step 4 above), you will be able to add new shortcut keys with this command:
printf '"ApplicationName"\n+Shortcut+Key\n' >> ~/.xbindkeysrc &&
killall xbindkeys ; xbindkyes
For example, this will make Ctrl+Shift+X launch xclock
:
printf '"xclock"\nControl+Shift+Mod2 + x\n' >> ~/.xbindkeysrc &&
killall xbindkeys ; xbindkyes
You could then create a little script that does it for you. Save the following lines as ~/bin/keyb.sh
:
#!/bin/bash
printf '"$1"\n$2\n' >> ~/.xbindkeysrc &&
killall xbindkeys ; xbindkyes
Make the script executable with chmod a+x ~/bin/keyb.sh
. You can now add a new shortcut with
keyb.sh firefox 'Control+Shift+Mod2 + x'
/usr/share/applications
on to your desktop or wherever you want it to appear, and make it executable? You can do that via command line if you want to :)