Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I know the easy way using the unity but is there a way to make a shortcut for chrome for example using the terminal.

share|improve this question

closed as unclear what you're asking by bodhi.zazen, Sneetsher, i08in, Radu Rădeanu, qbi May 6 at 21:11

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

2  
short cut how ? Start typing a command and use tab completion, how to create an alias, or how to write a .desktop file ? custom key strokes ? what ? –  bodhi.zazen May 6 at 16:54
    
i mean if i want to add shortcut to chrome on the desktop using the terminal how can you do that ? –  bebo May 6 at 17:36
    
See askubuntu.com/questions/106521/… . You make a .desktop file, you can place it is various locations. –  bodhi.zazen May 6 at 18:00
    
I am not sure what you mean by the easy way, but why not simply copy the existing desktop file from /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 :) –  Jacob Vlijm May 6 at 19:35

1 Answer 1

up vote 3 down vote accepted

One way of doing it is to use xbindkeys:

  1. Install xbindkeys

    sudo apt-get install xbindkeys
    
  2. Create the default settings file:

    xbindkeys --defaults > ~/.xbindkeysrc
    
  3. 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.

  4. Run xbindkeys. To make this permanent, add a line containing xbindkeys 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'
share|improve this answer

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