Setting Special Keybindings in NOP

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
User avatar
DaveS
Posts: 3685
Joined: Thu 09 Oct 2008, 16:01
Location: UK

Setting Special Keybindings in NOP

#1 Post by DaveS »

Most Laptops have an Fn key system to extend the range of their keyboards, and also some special keys, like the Windows menu keys, but these are often not recognised, or at least, not used in Linux.
This tutorial is intended to demonstrate how to do this in NOP, which uses the Xfce 4.4 desktop. Specifically QuirkyNOP, but other variants should be the same.
It consists of three steps: discovering the identity of the key as seen by X, binding that identity to a string that Xfce understands, then assigning a command to the key.
So. To begin, open a terminal window menu>utility>terminal, and simply type

Code: Select all

xev
and hit 'enter'.
This will bring up a little target box and leave the terminal window open on the desktop. Watch the terminal window, and hit the key you want to use. For this example, we will use the Windows Menu key.
Assuming X can recognise this key, this will bring up a bunch of text in the terminal window. Look for the keycode, usually 115, and make a note of the number.
OK, so now we have the key identity.
Next, we need to bind that identity to a string that Xfce understands.
So. First, create a text file in your root directory called .Xmodmap Note the dot at the start of the file name is important. Leave this (so far) blank file open. Now we need to find a suitable string that Xfce understands. These strings are all held in a text file at /usr/share/X11/XKeysymDB. Open this file and look for a suitable string, in this case its XF86MenuKB.
Then add the entry to .Xmodmap. This is the syntax:

Code: Select all

 keycode 115 = XF86MenuKB
and save the file. Now you have to 'bind' this so that Xfce will use it. Again open a terminal window and type

Code: Select all

 xmodmap .Xmodmap
and hit enter. Job done.

All that remains now is to tell Xfce to use this key with the command of your choice. In this example, we will set it to launch Firefox.
So. Menu>Settings>Xfce Settings Manager, and launch the keyboard section by clicking the icon. Choose the Application Shotcuts tab. Click the + button to add a command, and use the Open button to find the command you want, in this case, /usr/lib/firefox/firefox, and click OK. That little window will close and another will pop-up asking for the key. Just hit the key you want to use, in this case, the Windows Menu key, and you are done.

From now on, just hitting the Windows Menu key will launch Firefox for you.

You can add as many bindings as you like to .Xmodmap, then run xmodmap .Xmodmap via the terminal to set it, but watch out for creating conflicts.

Good Luck..................
Spup Frugal HD and USB
Root forever!

Post Reply