sonykeyd project

project (nearly) dead. no active development. only occasional fixes. be warned.

page: version 0.2, date: 2004.12.30
sonykeyd: version 0.2, date: 2004.12.30

sonykeyd is daemon that enables assigning actions to additional buttons found in many Sony Vaio laptops.
It requires sonypi driver compiled in into kernel and some experience with configuring and installing scripts in the system.
It comes with example script for control of volume, brightness and cdrom tray.


Description

Sony laptops has number of special keys. For example Sony Vaio FX240 has P1, P2, P3, and Fn key that can be used in combination with some standard keys (F1, F2, ..., 1, 2, E, S, D, Esc, ...) to perform some predefined actions. Other models may have Jogdial, Bluetooth or Capture keys.
These keys (combinations) doesn't belong to standard keyboard driver, so must use separate driver to be accessed. sonypi kernel driver will listen to them.

sonykeyd is program that waits for events on /dev/sonypi device, and passes names of keys pressed to a script/program.
Attached script allows to control volume, brightness and eject the cdrom.

This project was inspired by David Levitan's sonyfxd project.
Ideas used in sonykeyd are taken from sonypid (event reading) and acpid (handling events by user configurable shell script).

As this project didn't evaluate nearly at all since its initial version (0.01 in Apr 2002), you may prefer to use something that is developed more actively, eg.

Installation

  1. sonypi driver

    Compile recent 2.4 (2.4.7+) or 2.6 kernel. You must compile in sonypi driver.
    This description assumes that sonypi is compiled as an module, but you can configure it as solid part of the kernel as well.
    You will find relevant kernel option in
    (Device Drivers ->) Character devices -> Sony Vaio Programmable I/O Control Device support

    If your model doesn't have Jogdial button, you may need use newer kernel (2.4.19+) version as it has necessary changes.

  2. Next you have to add options for this module. Edit your /etc/modules.conf (or /etc/modprobe.conf for 2.6 kernel) 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!
  3. Create a /dev/sonypi special file:
    # mknod  /dev/sonypi c 10 63
    
    If your system (eg. Fedora Core 3) uses udev, please see docs, to find out how to make this device node permanent.
  4. You can now test if driver works, by downloading and running sonypid daemon. It should print names of Sony keys pressed.
  5. sonykeyd daemon

    Download source package: sonykeyd-0.2.tar.gz.
    Unpack it:
    $ tar -xzf sonykeyd-0.2.tar.gz
    
    Compile it:
    $ cd sonykeyd-0.2
    $ make
    
    You may have to modify Makefile and change /usr/src/linux/include path to wherever your kernel headers are.
  6. install driver (as root)
    # make install
    
    will simply copy sonykeyd file to /usr/local/sbin. You can do it by hand.

  7. create the script

    By default, when sonypi event is registered, /usr/local/sbin/sonykey.sh program (script) is called.
    Names of keys used are in the table (or in strings.c file in package)

    Bash script sonykey.sh included in package will do the following:
    Fn+F3: mute/unmute
    Fn+F4: select global/pcm volume for changing
    Fn+F5: select brightness for changing
    Fn+1:  decrease selected option
    Fn+2:  increase selected option
    Fn+E:  eject the cdrom
    This script calls aumix program to control volume, spicctrl program to control brightness, and eject program to eject cdrom tray.

    Feel free to extend or replace what the script do...

  8. make this configuration work

    Copy sonykey.sh to /usr/local/sbin, and make it executable. Eg:
    # cp scripts/sonykey.sh /usr/local/sbin
    # chmod 0700 /usr/local/sbin/sonykey.sh
    
  9. Make the directory where script will keep it's runtime temporary files
    # mkdir -p /var/local/sound/state
    
  10. Run the sonykeyd program. It will fork into background
    # ./sonykeyd
    
  11. Try it!
    Press Fn+F5, and Fn+1 several times... Does the screen get darker?
    Now play some music and press Fn+F4 and Fn+1. Any volume change?
    What about Fn+E -- eject?

  12. (optional) run daemon automatically on system startup...

    Sorry, this was tested on RedHat & Fedora Core 2 only. But should work on any system that uses config utility.

    copy sonypi to /etc/rc.d/init.d and make it executable:

    # cp scripts/sonypi /etc/rc.d/init.d
    # chmod 0755 /etc/rc.d/init.d/sonypi
    

    Install it.
    # chkconfig --add sonypi
    

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, email: jslupski at juljas dot net.
Contact me in case of any troubles, questions, opinions, ideas...
The newest version of this page can be found at: http://juljas.net/linux/vaiofx240/sonykeyd.html
Main Sony Vaio FX240 page: http://juljas.net/linux/vaiofx240/