1

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

4
  • 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 ?
    – Panther
    May 6, 2014 at 16:54
  • i mean if i want to add shortcut to chrome on the desktop using the terminal how can you do that ?
    – alkabary
    May 6, 2014 at 17:36
  • See askubuntu.com/questions/106521/… . You make a .desktop file, you can place it is various locations.
    – Panther
    May 6, 2014 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 :) May 6, 2014 at 19:35

1 Answer 1

3

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'

Not the answer you're looking for? Browse other questions tagged .