HP NC6120: Using the multimedia buttons in linux
By psichron (http://psichron.za.net)
(With help from
http://ale.freeshell.org/articles/hotkeys/hotkeys.html)
Requirements: xmodmap, amixer
This guide demonstrates how to bind some of the multimedia keys on the HP NC6120 to act as function keys (F13,F14,etc). At the end there is a short section on implementing them in KDE. Volume buttons and volume led are implemented.
Get the keycodes:
First of all, you have to know the keycodes these keys generate. Run xev in console and watch its output as you press the multimedia buttons. For my nc6120 I get:
| Key | keycode: |
| i | 187 |
| windows | 115 |
| FN+F3 | 223 |
| presentation | 148 |
| mute | 160 |
| volume up | 176 |
| volume down | 174 |
Bind to function keys:
The following script binds the keycodes to corresponding function key values. Create a file called keymap.sh and enter the following:
#!/bin/bash
xmodmap -e 'keycode 223=F17' # FN + F3
xmodmap -e 'keycode 148=F18' # presentation button
xmodmap -e 'keycode 187=F19' # i button
xmodmap -e 'keycode 115=F20' # windows button
xmodmap -e 'keycode 174=F21' # lower volume
xmodmap -e 'keycode 176=F22' # raise volume
xmodmap -e 'keycode 160=F23' # mute
exit 0
Next, make the script executable: chmod 755 keymap.sh and put it somewhere it will run when your window manager starts. For KDE, I put mine in: /home/USER/.kde/Autostart
Execute the script. Your multimedia keys will now act as additional function keys.
Volume scripts:
Create these three
scripts in a suitable directory (Mine is in /home/USER/bin)
mute
#!/bin/bash
## This script toggles the Master volume using amixer.
## (Toggles mute LED on HP nc6120)
## Carel van Wyk
amixer set Master toggle
exit 0
(Next two from
http://ale.freeshell.org/articles/hotkeys/hotkeys.html)
louder
#!/bin/bash
###########################################
# Copyright (C) 2005 Patrick A. Read
#
# louder - this shell script increases
# the volume
of the Master playback control
# in
alsamixer. Usage: louder [number]
# where
(optional) number is the number of
# clicks
you wish to increase the volume.
# Example:
louder 4 cranks up the volume
# four
steps. If you do not specify a
# number,
then louder will raise the
# volume one
step. NOTE: Alsamixer uses
# 32 steps
(0-31) in its volume controls.
###########################################
if [ "$1"
!= "" ]
then
VOLADJ=${1}+
else
VOLADJ="1+"
fi
amixer set
Master ${VOLADJ}
exit 0
###########################################
# end of
louder script
###########################################
softer
#!/bin/bash
###########################################
# Copyright
(C) 2005 Patrick A. Read
#
# softer -
this shell script decreases
# the volume
of the Master playback control
# in
alsamixer. Usage: softer [number]
# where
(optional) number is the number of
# "clicks"
you wish to decrease the volume.
# Example:
softer 3 softens the volume
# three
steps. If you do not specify a
# number,
then softer will lower the
# volume one
step. NOTE: Alsamixer uses
# 32 steps
(0-31) in its volume controls.
###########################################
if [ "$1"
!= "" ]
then
VOLADJ=${1}-
else
VOLADJ="1-"
fi
amixer set
Master ${VOLADJ}
exit 0
###########################################
# end of
softer script
###########################################
Now make these
scripts executable. chmod 755 mute louder softer
Implementing in KDE:
Access “System
Settings” on the K Menu. Click on “Regional & Accessibility”
-- “KHotKeys” (left) -- “New Group” (bottom) --
enter “Action Group name”. (Mine is “hotkeys” without the quotes).
Highlight the newly created action group, click “New Action” (bottom) and enter action name (e.g. mute).
Select “Action type:” - “Keyboard Shortcut -> Command/URL (simple)”
Click the “Keyboard Shortcut” tab (top), click on the button and press the appropriate key. (e.g. the mute button)
Click on the Command/URL Settings tab and enter the appropriate command (e.g. /home/USERNAME/bin/mute)
Click apply and repeat for other keys.
-----------------------
http://psichron.za.net/
System setup:
HP nc6120
kubuntu 5.10