Free Web Hosting Provider - Web Hosting - E-commerce - High Speed Internet - Free Web Page
Search the Web

sonykeyd project

very, very preliminary state!
page: version 0.01, date: 2002.04.02
sonykeyd: version 0.01, date: 2002.04.02

This project was inspired by David Levitan's sonyfxd project. Ideas used in sonykeyd are taken from sonypid (event readnig) and acpid project (handling events - running shell that has to deal with event).

Description

Sony laptops has number of special keys. My FX240 has P1, P2, P3, and Fn key that can be used in combination with F1, F2, ..., 1, 2, E, S, D, Esc, ... Other models has Jogdial, Bluetooth and Capture keys.
These keys cannot be used as standard ones, they doesn't belong to standard keyboard driver. But sonypi kernel driver gives access to them.
Sonykeyd is program that waits for event on /dev/sonypi device, and passes the name of key pressed to a script/program.
Attached script allows to control volume, brightness and eject the cdrom.

Installation

  1. sonypi driver

    Compile recent 2.4 kernel. You must compile sonypi driver. This description assumes it is compiled as an module, but can configure it as solid part of the kernel
    It is option "<M> Sony Vaio Programmable I/O Control Device support" in "Character devices" section of kernel configuration.

    If your model doesn't have Jogdial button, you should use this patch, which is part of -ac kernel patch. Probably 2.4.19 kernel will have this patch integrated.
    If you don't apply the patch, your P2, P3, will not work, and P1 will act as Jogdial. Other keys will work properly.

    Next you have to add options for this module. Edit your /etc/modules.conf file, and add these lines:

            alias char-major-10-63 sonypi
            options sonypi minor=63 nojogdial=1
          
    Of course if your model has Jogdial, clear "nojogdial=1" option!

    Create a /dev/sonypi special file:

            $ mknod  /dev/sonypi c 10 63
          

    You can now test if driver works, by downloading and running sonypid daemon. It should print names of Sony keys pressed.

  2. sonykeyd daemon

    Download source package: sonykeyd.tar.bz2.

    Unpack it:

            $ tar -xjf sonykeyd.tar.bz2
          
    or (if it doesn't work):
            $ bunzip2 -c sonykeyd.tar.bz2 | tar -xvf -
          

    Make it:

            $ cd sonykeyd
            $ make
          
    You may have to modify Makefile and change /usr/src/linux/include to wherever your kernel is.

  3. install driver
            # make install
          
    will simply copy sonykeyd file to /usr/local/sbin. You can do it by hand.

  4. create the script

    By default, when sonypi event is registered, /usr/local/sbin/sonykey.sh program (script) is called. As a first parameter name of key pressed is passed. Names of keys are in the table.

    My bash script will do as following:

            Fn+F3: mute/unmute
            Fn+F4: select global/pcm volume for changing
            Fn+F5: select brightness for changing
            Fn+1:  decrease amount of selected option
            Fn+2:  increase amount of selected option
            Fn+E:  eject the cdrom
          
    This script calls ALSA aumix program to control volume, spicctrl program to control brightness, and eject (eject package) program.

    I know it is not perfect: it remembers it's options (a mute state, option selected for changing) in filesystem.
    But this is only an example. Modify it, and give the sonypi keys meaning you want!

  5. make it work

    Run the sonykeyd program. It will fork into background
    Default program run on event catch is /usr/local/sbin/sonykey.sh but you can pass other name as an argument to sonykeyd.

    Copy your program/script to /usr/local/sbin as sonykey.sh, and make it executable. Eg:

            $ cp sonykey.sh /usr/local/sbin
            $ chmod 0700 /usr/local/sbin/sonykey.sh
          

    If you use an example sonykey.sh script, you must additionally:

            $ mkdir -p /var/local/sound/state
          
    and has ALSA working, eject utility on path and spicctrl in /usr/local/sbin/.

    Try it!
    Press Fn+F5, and Fn+1 several times... Does it get darker?
    Now play some music and press Fn+F4 and Fn+1. Any change?

  6. (optional) make it work always...

    I have RedHat.
    I use RedHat.
    I know RedHat.
    This is for RedHat. Sorry.
    If you can write description for other distributions...do it! Many people Debian/Mandrake/... users will be grateful

    If you want daemon running after each system start you can copy my RedHat "service" script. It is modified (and cleaned) version of sshd startup script, but works for me.

    Here it is: sonypi script
    copy it to /etc/rc.d/init.d and create links:

            $ cp sonypi /etc/rc.d/init.d
            $ chmod 0755 /etc/rc.d/init.d/sonypi
            $ ln -s ../init.d/sonypi /etc/rc.d/rc2.d/S86sonypi
            $ ln -s ../init.d/sonypi /etc/rc.d/rc3.d/S86sonypi
            $ ln -s ../init.d/sonypi /etc/rc.d/rc4.d/S86sonypi
            $ ln -s ../init.d/sonypi /etc/rc.d/rc5.d/S86sonypi
            $ ln -s ../init.d/sonypi /etc/rc.d/rc0.d/K02sonypi
            $ ln -s ../init.d/sonypi /etc/rc.d/rc6.d/K02sonypi
          

TODO

Keys table

eventsonykeyd nameFX240
Unknown eventunknown 
Jogdial Downjd-down 
Jogdial Upjd-up 
Jogdial Down & Pressedjd-down-P 
Jogdial Up & Pressedjd-up-P 
Jogdial Pressedjd-P 
Jogdial Releasedjd-R 
Capture Pressedcp-P 
Capture Releasedcp-R 
Capture Partial Pressedcp-partP 
Capture Partial Releasedcp-partR 
Fn-Esc Pressedfn-escworks
Fn-F1 Pressedfn-f1works
Fn-F2 Pressedfn-f2works
Fn-F3 Pressedfn-f3works
Fn-F4 Pressedfn-f4works
Fn-F5 Pressedfn-f5works
Fn-F6 Pressedfn-f6works
Fn-F7 Pressedfn-f7works
Fn-F8 Pressedfn-f8works
Fn-F9 Pressedfn-f9works
Fn-F10 Pressedfn-f10works
Fn-F11 Pressedfn-f11works
Fn-F12 Pressedfn-f12works
Fn-1 Pressedfn-1works
Fn-2 Pressedfn-2works
Fn-D Pressedfn-dworks
Fn-E Pressedfn-eworks
Fn-F Pressedfn-fworks
Fn-S Pressedfn-sworks
Fn-B Pressedfn-b 
Bluetooth Button Pressedp-bt 
P1 Pressedp-p1works
P2 Pressedp-p2works
P3 Pressedp-p3works

Author: Jan Slupski, jslupski@email.com .
Contact me in case of any troubles, questions, opinions, ideas...
The newest version can be found on: http://www.pm.waw.pl/~jslupski/vaio/sonykeyd.html
Main site: http://www.pm.waw.pl/~jslupski/vaio/