Tips for using "extra" keyboard keys. Mini-HOWTO (fwd)

csm csm at lunar-linux.org
Thu Dec 18 17:46:03 GMT 2003


this is a very interesting email... I thought it might be useful to people
who have these type of keyboards.

---------- Forwarded message ----------
Date: Thu, 18 Dec 2003 16:17:56 +0000
From: Keith G. Robertson-Turner <redhat-forums at genesis-x.nildram.co.uk>
Reply-To: fedora-list at redhat.com
To: fedora-list at redhat.com
Subject: Tips for using "extra" keyboard keys. Mini-HOWTO

I recently bought a new keyboard, and as with most new keyboards these
days, it has a lot of custom keys that won't do anything (out of the box)
on Linux.

Getting these keys to do anything useful, is a bit involved (and time
consuming) but not especially difficult. It also depends on a number of
different factors, such as which window manager you're using.

For those running FC1, Gnome 2.4 and Metacity, and for the benefit of
those who haven't figured out how to use those extra keys yet, here's a
quick HOWTO:

Steps 2 and 3 should be run a root.

1) ...

Run "xev" in a terminal ... it's part of XFree86-tools

Press one of the "custom" keys.

Look carefully at the output:

KeyPress event, serial 23, synthetic NO, window 0x2a00001,
    root 0x7d, subw 0x0, time 2400405, (126,229), root:(134,275),
    state 0x0, keycode 229 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 0 bytes:  ""

The info you need above is "keycode 229" - in this example, this is the
"search" key on a Logitech Deluxe Access" keyboard.

2) ...

Using your favourite text editor, edit /etc/X11/Xmodmap (part of the
xinitrc package).

Add the following line:

keycode 229 = LogiSearch

Save and quit.

Note: I chose the name "LogiSearch" arbitrarily. You can give it any name
you like, so long as you keep a note of that name - and remember it is
case sensitive (as with most things on Linux).

3) ...

Edit /usr/X11R6/lib/X11/XKeysymDB (part of the XFree86-libs-data package).

Choose a range of identifiers not already in use, on my system I chose
10090001 upwards (this is a hex value).

Add the following line:

LogiSearch     :10090001

Save and quit. Note that by default this file is read only, so you will
need to "force" save - e.g. with "w!" using vi.

4) ... ( As non-root )

Run gconf-editor (changes here are on a per-account basis)

Navigate to apps -> metacity -> global_keybindings.

Right-click on "run_command_2", and chose "Edit key..."

In the "Key value:" box, type "LogiSearch" without the quotes.

Navigate to apps -> metacity -> keybinding_commands.

Right-click on "command_2", and chose "Edit key..."

In the "Key value:" box, type "gnome-search-tool", without the quotes
(part of the gnome-utils package)

Quit gconf-editor and logout (restart X), no need to reboot.

That's it. Hitting the "search" key will now launch gnome-search-tool.

Remember you have to run gconf-editor for *every* user account you wish to
have access to the custom keys.

One key down, twenty to go ... sigh.

I managed to set up xmms to use the multimedia keys, using xmms-shell
(http://freshmeat.net/projects/xmms-shell/).

Here's a sample from my configs:

/etc/X11/Xmodmap
keycode 236 = LogiEmail
keycode 237 = LogiMedia
keycode 176 = LogiVolUp
keycode 174 = LogiVolDn
keycode 162 = LogiPlay
keycode 164 = LogiStop
keycode 144 = LogiBack
keycode 153 = LogiFfwd
keycode 160 = LogiMute

/usr/X11R6/lib/X11/XKeysymDB
LogiEmail               :10090001
LogiMedia               :10090002
LogiVolUp               :10090003
LogiVolDn               :10090004
LogiPlay                :10090005
LogiStop                :10090006
LogiBack                :10090007
LogiFfwd                :10090008
LogiMute                :10090009

gconf settings
global_keybindings
run_command_2     LogiEmail
run_command_3     LogiMedia
run_command_4     LogiVolUp
run_command_5     LogiVolDn
run_command_6     LogiPlay
run_command_7     LogiStop
run_command_8     LogiBack
run_command_9     LogiFfwd
run_command_10    LogiMute

keybinding_commands
command_2     evolution
command_3     xmms
command_4     aumix-minimal -w +1
command_5     aumix-minimal -w -1
command_6     sh /home/kgr/scripts/xmms-toggle-play.sh
command_7     xmms-shell -e stop
command_8     xmms-shell -e back
command_9     xmms-shell -e forward
command_10    sh /home/kgr/scripts/xmms-toggle-mute.sh

#!/bin/bash
# xmms-toggle-mute.sh

xmmsstatus=$(xmms-shell -e status >/dev/null 2>&1)
statusresult=$?
if [ "$statusresult" -eq 1 ]
then
exit 1
fi

getvol ()
{
echo $3
}

if [ -f /tmp/xmms-volume.save ]
then
   read oldvolume </tmp/xmms-volume.save
else
   oldvolume=80
fi

xmmsstatus=$(xmms-shell -e status | tail -n 5 | head -n 1)
if [ -n "$xmmsstatus" ]
then
volval=$(getvol $xmmsstatus)
fi

if [ "$volval" -eq 0 ]
then
   xmms-shell -e "volume $oldvolume" >/dev/null 2>&1
else
   echo >/tmp/xmms-volume.save $volval
   xmms-shell -e "volume 0" >/dev/null 2>&1
fi
exit 0

#!/bin/bash
# xmms-toggle-play.sh

xmmsstatus=$(xmms-shell -e status >/dev/null 2>&1)
statusresult=$?
if [ "$statusresult" -eq 1 ]
then
exit 1
fi

xmmsstatus=$(xmms-shell -e status | head -n 1 | grep "Current song:")
if [ -n "$xmmsstatus" ]
then
xmms-shell -e play >/dev/null 2>&1
else
xmms-shell -e pause >/dev/null 2>&1
fi

exit 0

I assume there are ways of getting all this to work under different window
managers, YMMV. Also, I've been toying with the idea of getting a
"Logitech diNovo Media Desktop" keyboard. This thing is essentially a USB
keyboard using Bluetooth for wireless transmission. Getting it to work
(including the extra keys) under Linux will probably be a bit more
involved than the relatively simple steps here. My next project, I guess.

In the meantime, it would be great if all the above steps could be
combined into a nice GUI "keymap configurator" for Gnome/KDE. Any takers?

-
Keith



--
fedora-list mailing list
fedora-list at redhat.com
To unsubscribe: http://www.redhat.com/mailman/listinfo/fedora-list


More information about the lunar mailing list