Logitech keyboard/mouse?

Daniel Bye freebsd-questions at slightlystrange.org
Thu Dec 27 11:14:32 PST 2007


On Thu, Dec 27, 2007 at 01:18:19PM -0500, Robert Huff wrote:
> 
> 	As long as we're in the viciity:
> 	I have a Logitech i-Touch keyboard; standard 104 (or whatever
> it is these days) setup plus a dozen extra buttons and two dials.
> 	Great product.
> 	It would be even greater if
> 	a) I could get X to register/comunicate all the extra stuff
> 	and
> 	b) programs understood and used those inputs.
> 	Has anyone seen this done?  I'd dearly loce to be able to use
> the little dial by the TAB key for volume control in xmms.

I tinkered with this stuff a while ago. Let me see if I can remember
how (an object lesson in making copious notes whenever you try something
new, I guess...)

To find out what keycodes your extra keys are bound to, run xev(1) from
an Xterm or similar. With your mouse pointer over the little window that
pops up, hit each extra key you are interested in and make a note of its
keycode value. Quit xev(1) and edit or create ~/.Xmodmap, which allows
you to assign keysyms to particular keycodes, etc (see xmodmap(1) for
the full story). On my keyboard, turning the dial clockwise generates
keycode 176, and anti-clockwise 174 which I map to the XF86AudioRaiseVolume
and XF86AudioLowerVolume keysyms:

keycode 176 = XF86AudioRaiseVolume
keycode 174 = XF86AudioLowerVolume

I also have a mute button next to the dial which generates 140:

keycode 140 = XF86AudioMute

(A full list of keysyms can be found in /usr/local/lib/X11/XKeysymDB)

For this to be useful, you need to figure out how your window manager 
handles keyboard customisation.[1] Under XFCE4, the Keyboard settings
applet allows creation of keyboard shortcuts by attaching commands
to keysyms. For example, to change the mixer volume, I have 
`aumix -v +10' assigned to XF86AudioRaiseVolume and `aumix -v -10'
assigned to XF86AudioLowerVolume. (aumix is available in the ports).
I have assigned a custom shell script to the mute button (XF86AudioMute)
which toggles the volume on or off:

#!/bin/sh -x

# If we are currently playing, mute the speakers and register current
# volume level in /tmp/mute-${XINE_PID}
#
# If mute (ie, if mute-${XINE_PID} exists), restore volume to the level
# recorded in the file, and remove the file.

XINE_PID=$(pgrep xine)

if [ -f "/tmp/mute-${XINE_PID}" ]
then
  VOL=$(cat "/tmp/mute-${XINE_PID}")
  aumix -v${VOL}
  rm "/tmp/mute-${XINE_PID}"
else
  VOL=$(aumix -q | awk '/^vol/ {print $2}' | sed -e 's/,//')
  echo ${VOL} > "/tmp/mute-${XINE_PID}"
  aumix -v0
fi

It's a little naive, but it works for me (TM). I'm sure much more sophist-
icated and robust solutions are to be found!

I have also created a very simplistic play/pause/resume script which is
bound to XF86AudioPlay (keycode 162 in my case):

#!/bin/sh

# Play/Pause/Unpause control for Xine.
# Invoked from the XFCE4 keyboard shortcuts.

XINE_PID=$(pgrep xine)

if [ -f "/tmp/play_pause-${XINE_PID}" ]
then
  rm "/tmp/play_pause-${XINE_PID}" && exec xine -S play
else
  touch "/tmp/play_pause-${XINE_PID}" && exec xine -S pause
fi

Again, pretty naive, but it works here. 

Once you have customised your .Xmodmap, you can ativate the changes by
adding to your ~/.xsession or ~/.xinitrc

xmodmap /path/to/your/home/.Xmodmap

Obviously, the same command can be used to load your modifications
without logging off.

HTH

Dan

[1] http://gentoo-wiki.com/HOWTO_Use_Multimedia_Keys gives details
for various window managers.
-- 
Daniel Bye
                                                                     _
                                              ASCII ribbon campaign ( )
                                         - against HTML, vCards and  X
                                - proprietary attachments in e-mail / \
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20071227/7ecb46dd/attachment.pgp


More information about the freebsd-questions mailing list