2

I want to add a new Hotkey: When I press F1 it will do the same as Shift+F1 does. I have added a new Custom Shortcut (System -> Keyboard) but I don't know the command to run like we press F1. I appreciate your help.

2 Answers 2

3


If you want to add a new Hotkey, for example when you press Shift+F1 call F1 commands, you will need an extra softwae as xbindkeys: xdotool or xte. I follow by using xte.

1. Install xbindkeys:

sudo apt-get install xbindkeys

2. Then install xte:

sudo apt-get install xautomation

The syntax for xte is like this: xte 'command key/mousebutton/xyCoordinates'

for examples:

  • To call a single key press: xte 'key keyName'
  • To call a key combination: xte 'keydown keyName' 'keydown secondKeyName' 'keyup keyName' 'keyup secondKeyName
  • And more! Read man xte

3. Find the name of a key: xbindkeys allows us to use the -k handle to find the name of a key or key combination. Run xbindkeys -k and press a key or key combination.

If you pressing Shif+F1 your output will look something similar to this:

"(Scheme function)"
    m:0x11 + c:67
    Shift+Mod2 + F1

The basic syntax of xbindkeysrc commands is like this:

"Command to run (in quotes)"
key to associate with command (no quotes)  

so as you can see at above.

4. Create a file named .xbindkeysrc in your home directory:

touch $HOME/.xbindkeysrc

5. Now open .xbindkeysrc file.

gedit .xbindkeysrc

6. Bind key/key combination to another key/key combination:

So according to first example of xte syntax in step 2, we have this:

xte 'key keyName'

Ok, now combine this command with output of pressing Shif+F1 in step 3 and put in or type into .xbindkeysrc file that we opened in step 5. like this:

"xte 'key F1'"
Shift+Mod2 + F1

7. Save it and exit. Now you might notice your command doesn't work yet, that's because xbindkeys isn't running. To start it just run xbindkeys from a terminal. Your Shif+F1 should now start your F1 command!

According to this Q/A by Seth

1

When you press the F1 key it opens the system documentation browser (yelp).

You can for instance, access the Nautilus help with:

yelp help:ubuntu-help/files

From yelp man pages:

NAME
       yelp — browse system documentation

USAGE
       yelp [file]

       The GNOME Help Browser includes detailed documentation for the majority
       of applications, utilities and other components, such as the  panel  or
       the Nautilus file manager.

       Yelp  can  display  some HTML and XML files when passed on the command-
       line, but it's primarily called from applications.

       You can also start Yelp by choosing Desktop->Help.  This will show  the
       top-level  help  system  page, listing all GNOME documents conveniently
       organized by topic.

OPTIONS
       This program accepts all the standard GNOME  and  GTK+  options,  which
       follow  the  usual  GNU command line syntax, with long options starting
       with two dashes (`-'). To get  more  information  about  these  options
       launch Yelp with the `--help' argument.

To know which command(s) are executed by shortcut keys, open a Terminal and look at the result of the ps -aef command, one of the last process is your command:

[...]
root      9013     2  0 21:18 ?        00:00:00 [kworker/u16:0]
sylvain   9036  2003 19 21:20 ?        00:00:00 yelp help:gnome-terminal
sylvain   9054  8851  0 21:21 pts/14   00:00:00 ps -aef
1

You must log in to answer this question.

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