Difference between revisions of "Multimedia Key Mapping in Mythbuntu using xmodmap"
(Created page with "=== background === <blockquote cite="https://wiki.ubuntu.com/NotifyOSD#Volume_changes">"When you change the display’s or keyboard backlight’s brightness using keyboard ho...") |
(No difference)
|
Revision as of 14:39, 27 February 2015
background
"When you change the display’s or keyboard backlight’s brightness using keyboard hotkeys, the change in brightness should be shown in a confirmation bubble with a gauge. "This is the KNotification API. https://wiki.ubuntu.com/NotifyOSD#Volume_changes The Xfce desktop I see it for volume up and down, those seem to be mapped in the distribution I use - Xubuntu.
What's it trapped by? Well the kernel generates the scancode, which is different from a keycode. Don't confuse the two. There is a mapping for scancode to keycode at the kernel level. When you map a scancode to a different key with xmodmap there isn't a problem unless the scancode is already assigned to something, a good example is volume up and down. The new mapping doesn't apply after running xmodmap, however, will stop functionality of the volume control. After you reboot the system the new mapping will take effect by those that were previously intercepted. Gnome, KDE and Xfce will intercept some of the hotkeys. Adjusting the volume or pressing mute will result in a screen icon appearing generated by the KNotification API and resulting in the change occurring in PulseAudioMixer and/or ALSA.
Keycode values once were mapped to a text string called a keysym in a file called XF86keysym.h that is compiled into the kernel. When you install a distribution such as Mythbuntu the keysym strings are already in the kernel. They are like global constants that can be used by other software. The string values are used globally without the leading 3 characters. Not all of the keysym constants cover every hotkey. Multimedia keyboards with volume controls:
Volume Up and Down: keycode 176 = XF86AudioRaiseVolume and keycode 174 = XF86AudioLowerVolume
configuration and activation
1. Find your keycodes
First you need to install a utility such as xev to get the keycodes for the buttons you wish to map. Many of these buttons are relatively standard, however, not standardized. Some keycodes differ from one manufacturer to the next.
2. Install and configure Xmodmap
It is not necessary to do this under a privileged account. You want to do it as the MythTV user account. Create the xmodmap mapping file.
vi ~/.Xmodmap
Populate it with the mappings you desire. Take a look at our example file:
! Keymap for Aerb Remote Control ! 172 Play / Pause ! 174 Stop ! 056 Back (Rewind) ! 041 Forward ! 173 Last track ! 171 Next track ! 121 Mute ! 122 Volume up ! 123 Volume down keycode 176 = Left keycode 216 = Right keycode 173 = Home keycode 171 = End keycode 69 = Escape keycode 172 = p P keycode 135 = m M keycode 180 = Menu keycode 163 = i I keycode 68 = w W
3. Test the configuration
4. Reboot the system
If you do not reboot the system then you will find some of your key mappings will not come though. On Mythbuntu you will find that buttons such as PLAY are mapped to activate the DVD drive. If you try to remap to something like in our example the change will not be effective until the system is restarted. I know, kinda lame like the old Microsoft Windows. Technically a system restart is not necessary if X.org and some other processes are restarted, however, it is just easier to reboot.