Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Dec 2007 19:14:27 +0000
From:      Daniel Bye <freebsd-questions@slightlystrange.org>
To:        freebsd-questions@freebsd.org
Subject:   Re: Logitech keyboard/mouse?
Message-ID:  <20071227191427.GA1076@torus.slightlystrange.org>
In-Reply-To: <18291.60523.175555.968377@jerusalem.litteratus.org>
References:  <80f4f2b20712270836x43c08626yc274eeba5c71f7fe@mail.gmail.com> <1581622098.20071227205006@bk.ru> <18291.60523.175555.968377@jerusalem.litteratus.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--AqsLC8rIMeq19msA
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Dec 27, 2007 at 01:18:19PM -0500, Robert Huff wrote:
>=20
> 	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 =3D XF86AudioRaiseVolume
keycode 174 =3D XF86AudioLowerVolume

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

keycode 140 =3D 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=20
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=20
`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=3D$(pgrep xine)

if [ -f "/tmp/mute-${XINE_PID}" ]
then
  VOL=3D$(cat "/tmp/mute-${XINE_PID}")
  aumix -v${VOL}
  rm "/tmp/mute-${XINE_PID}"
else
  VOL=3D$(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=3D$(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.=20

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.
--=20
Daniel Bye
                                                                     _
                                              ASCII ribbon campaign ( )
                                         - against HTML, vCards and  X
                                - proprietary attachments in e-mail / \

--AqsLC8rIMeq19msA
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4 (FreeBSD)

iD8DBQFHc/mTixf5fBYiFmoRAig/AKDKW6KwKhRHaesvJAMwl4K9dixWXwCeNvXm
ay5tAVsX90XWdXNS5DVqL/8=
=zj2/
-----END PGP SIGNATURE-----

--AqsLC8rIMeq19msA--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071227191427.GA1076>