LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Configure multimedia keys in Slackware 12.2 and KDE (https://www.linuxquestions.org/questions/slackware-14/configure-multimedia-keys-in-slackware-12-2-and-kde-691029/)

El Nigromante 12-16-2008 02:17 PM

Configure multimedia keys in Slackware 12.2 and KDE
 
Hello,

Surely most of you know how to set up the special or "multimedia" keys in some keyboards. There are also many pages in the Internet explaining the process. However, to save you all that google-ing, I explain here the steps (I found this thread quite useful http://dev-loki.blogspot.com/2006/04...xmodmap.html):

1) First of all, the kernel must map the scan code from the key to a known key code.

In some cases that mapping is already done. In other cases it is not. In order to know this, you can run a "tail -f /var/log/syslog" command as root, and press the target key(s). If you see something like this:

Code:

Dec 16 17:36:58 sanson kernel: atkbd.c: Unknown key pressed (translated set 2, code 0xa6 on isa0060/serio0).
Dec 16 17:36:58 sanson kernel: atkbd.c: Use 'setkeycodes e026 <keycode>' to make it known.
Dec 16 17:36:58 sanson kernel: atkbd.c: Unknown key released (translated set 2, code 0xa6 on isa0060/serio0).
Dec 16 17:36:58 sanson kernel: atkbd.c: Use 'setkeycodes e026 <keycode>' to make it known.

then you have to map that key in the kernel using the "setkeycodes" command (as reported by the kernel in the messages above). You should make an init script with all the required mappings, so they are loaded each time your computer boots, like this one:

Code:

#!/bin/bash
#
# /etc/rc.d/rc.localkeys
#
# Set special keys in the kernel.
#
# Refer to /usr/include/linux/input.h for the appropriate keycode values.

KEY_HOMEPAGE=172
KEY_WWW=150
KEY_CALC=140
KEY_HELP=138

setkeycodes e015 $KEY_HOMEPAGE
setkeycodes e023 $KEY_WWW
setkeycodes e06e $KEY_CALC
setkeycodes e026 $KEY_HELP

You can have a look at the "input.h" header and use the "standard" key code values for your keys, according to their intended functions.

Then, make your /etc/rc.d/rc.localkeys executable and put something like this in /etc/rc.d/rc.local:

Code:

#!/bin/sh
#
# /etc/rc.d/rc.local:  Local system initialization script.
#
# Put any local startup commands in here.  Also, if you have
# anything that needs to be run at shutdown time you can
# make an /etc/rc.d/rc.local_shutdown script and put those
# commands in there.

if [ -x /etc/rc.d/rc.localkeys ]; then
  /etc/rc.d/rc.localkeys
fi

2) You now should map the X key codes to the corresponding key symbols.

X key codes are not the same than kernel key codes (I have not found the correspondence between both groups of values yet :scratch:). The best way to know the X key code for any given key is running the "xev" program from X (in an X console), then pressing the target key, and taking note of the key code it logs. For an example:

Code:

KeyRelease event, serial 34, synthetic NO, window 0x1600001,
    root 0x13b, subw 0x0, time 2355334, (656,465), root:(660,490),
    state 0x0, keycode 174 (keysym 0x1008ff11, XF86AudioLowerVolume), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False

Here I pressed the "lower volume" key (I have it already mapped to the "XF86AudioLowerVolume"), which has an X key code value = "174".

Taking note of those values, you should now make an /etc/X11/xinit/.Xmodmap file, like this one:

Code:

!
! /etc/X11/xinit/.Xmodmap
!
! Set special keys in Xorg
!
! Refer to /usr/share/X11/XKeysymDB for the appropriate symbols.

keycode 178 = XF86HomePage
keycode 130 = XF86WWW
keycode 236 = XF86Mail
keycode 161 = XF86Calculator
keycode 245 = XF86LightBulb
keycode 176 = XF86AudioRaiseVolume
keycode 174 = XF86AudioLowerVolume
keycode 160 = XF86AudioMute
keycode 223 = XF86Sleep

This file will be passed as an argument to /usr/bin/xmodmap each time you log into your X session, so all those keys are mapped to their corresponding symbols. As stated in the comment, you can look the /usr/share/X11/XKeysymDB file to know the X symbols suitable for your keys' functions.

3) The last step is setting up your configured keys in KDE.

You can do it globally, in KDE Control Center -> Regional & Accessibility -> Input Actions (or also in Keyboard shortcuts), and you can also do it per application, in the settings menu.

That's all :)

T3slider 12-16-2008 07:16 PM

I haven't tried this yet, but it looks as though a few buttons I couldn't see in xev produce output in /var/log/syslog, and I should be able to map them using your guide. I didn't really look into this, but I was (mildly) annoyed that I couldn't get keycodes for those keys. Thanks a lot!


All times are GMT -5. The time now is 04:32 AM.