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).
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.
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.
# make install
will simply copy sonykeyd file to /usr/local/sbin.
You can do it by hand.
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!
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?
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
| event | sonykeyd name | FX240 |
|---|---|---|
| Unknown event | unknown | |
| Jogdial Down | jd-down | |
| Jogdial Up | jd-up | |
| Jogdial Down & Pressed | jd-down-P | |
| Jogdial Up & Pressed | jd-up-P | |
| Jogdial Pressed | jd-P | |
| Jogdial Released | jd-R | |
| Capture Pressed | cp-P | |
| Capture Released | cp-R | |
| Capture Partial Pressed | cp-partP | |
| Capture Partial Released | cp-partR | |
| Fn-Esc Pressed | fn-esc | works |
| Fn-F1 Pressed | fn-f1 | works |
| Fn-F2 Pressed | fn-f2 | works |
| Fn-F3 Pressed | fn-f3 | works |
| Fn-F4 Pressed | fn-f4 | works |
| Fn-F5 Pressed | fn-f5 | works |
| Fn-F6 Pressed | fn-f6 | works |
| Fn-F7 Pressed | fn-f7 | works |
| Fn-F8 Pressed | fn-f8 | works |
| Fn-F9 Pressed | fn-f9 | works |
| Fn-F10 Pressed | fn-f10 | works |
| Fn-F11 Pressed | fn-f11 | works |
| Fn-F12 Pressed | fn-f12 | works |
| Fn-1 Pressed | fn-1 | works |
| Fn-2 Pressed | fn-2 | works |
| Fn-D Pressed | fn-d | works |
| Fn-E Pressed | fn-e | works |
| Fn-F Pressed | fn-f | works |
| Fn-S Pressed | fn-s | works |
| Fn-B Pressed | fn-b | |
| Bluetooth Button Pressed | p-bt | |
| P1 Pressed | p-p1 | works |
| P2 Pressed | p-p2 | works |
| P3 Pressed | p-p3 | works |