Talk:Multimedia Keys

From Free Knowledge Base- The DUCK Project: information for everyone
Revision as of 11:19, 23 February 2015 by Admin (Talk | contribs)

Jump to: navigation, search

MythTV: Keyboard Special Keys

A great many keyboards are available with "special" keys, many of which are of interest to MythTV users with functions printed on them like "Vol +", "Vol -". There are more keyboards out there than are likely to ever be documented in a wiki like this... So, if you have a keyboard with the "special" keys that you would like to put to use, how do you do that, with examples drawn from Muthbuntu 11.04 "Natty Narwhal". Further while the focus here is on keyboards, the same rules/instructions apply to other devices that look to the system as "keyboards", such as PC cases with media buttons.

First program we need is "xev" which you can get through the package manager or by pulling up a terminal under X-windows and running "sudo apt-get install xev". You will want pen and paper (or maybe a second computer) to make notes for the next step. We run "xev" this will display in the terminal window what events it sees. Events to xev include keyboard keys being pressed, keyboard keys being release, mouse movements, etc.. Once xev is running pressing and releasing one of the special keys will generate something like the following on screen:

KeyPress event, serial 36, synthetic NO, window 0x4a00001,
    root 0x1ad, subw 0x0, time 20577657, (1029,913), root:(1033,938),
    state 0x10, keycode 164 (keysym 0x1008ff30, XF86Favorites), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False
KeyRelease event, serial 36, synthetic NO, window 0x4a00001,
    root 0x1ad, subw 0x0, time 20577669, (1029,913), root:(1033,938),
    state 0x10, keycode 164 (keysym 0x1008ff30, XF86Favorites), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

In our case all we care about is the number that follows the word "keycode", in the above example 164. Once you have your list of keys (or while your collecting your list if you are using a second computer) you can create the /home/{mythtv user}/.Xmodmap file. In the .Xmodmap file you will tie the special keys to what you want them to mean, so, for the above we might do something like:

! Keymap for Brand XYZ Model 123 keyboard
! Skip Back
keycode 164 = Left

Any line that starts with an exclamation mark is treated as a comment and ignored. A full list of the codes that xmodmap knows about (like "Left" as in left arrow key) can be seen in the file keysymdef.h (which you will likely have to dig-up on line). When looking through the keysymdef.h file remember to ignore "XK_". A typical .Xmodmap file when done will look something along the likes of the following:

! Keymap for Brand XYZ Model 123 keyboard  
! Skip Back
keycode 999 = Left
! Skip Forward
keycode 999 = Right
! Stop
keycode 999 = Escape
! PlayPause
keycode 999 = P
! VolUp
keycode 999 = bracketright
! VolDn
keycode 999 = bracketleft
! Mute
keycode 999 = bar

To start the above immediately type:

xmodmap /home/{mythtv user}/.Xmodmap

Otherwise, the script /etc/gdm/Xsession is run during the the Mythbuntu start-up and if it sees the file "/home/{user name}/.Xmodmap" it will auto-run "xmodmap /home/{user name}/.Xmodmap".

Once the above is up and running satisfactorily, the last step is to add what you have learned back to this wiki, so nobody else will have to go through the same grunt work of mapping keys if they have the same make / model of keyboard as you. Retrieved from "http://www.mythtv.org/wiki?title=Keyboard_Special_Keys&oldid=52707"

related links

To configure keys with xmodmap, you need a configuration file. I have provided two examples that work on my Hardy and Jaunty systems. Hopefully, one of them will work for you without change. At least they should serve as a starting point to get the multimedia keys working on your system.

Copy the following text to $HOME/xmodmap.hardy

keycode 160 = XF86AudioMute NoSymbol XF86AudioMute NoSymbol XF86AudioMute
keycode 174 = XF86AudioLowerVolume NoSymbol XF86AudioLowerVolume NoSymbol XF86AudioLowerVolume
keycode 176 = XF86AudioRaiseVolume NoSymbol XF86AudioRaiseVolume NoSymbol XF86AudioRaiseVolume
!keycode 153 = XF86AudioNext NoSymbol XF86AudioNext NoSymbol XF86AudioNext
keycode 153 = Z
!keycode 162 = XF86AudioPlay XF86AudioPause XF86AudioPlay XF86AudioPause XF86AudioPlay XF86AudioPause
keycode 162 = P
!keycode 144 = XF86AudioPrev NoSymbol XF86AudioPrev NoSymbol XF86AudioPrev
keycode 144 = Q
!keycode 164 = XF86AudioStop XF86Eject XF86AudioStop XF86Eject XF86AudioStop XF86Eject
keycode 164 = T
! Internet Explorer key
keycode 178 = XF86HomePage NoSymbol XF86HomePage NoSymbol XF86HomePage
! Power/Standby key
keycode 223 = XF86Sleep NoSymbol XF86Sleep NoSymbol XF86Sleep