At a long time, people have said on jdmouse like, "Hard coding is not refined" or "Less configurable"..
At last, I found an ultimate solution.
Throw to others.
Jdmouse only does event receiving and interpretation, invoke external programs to command execution. Then, backlight and sound volume control, which previous version of jdmouse has, was purged to externals.
But with jogdial events, because of event frequency and identity of its name, jdmouse still handles.
Here is a chart for relation of programs.
sonypi.ko -> jdmouse* -> ~/.jdmouse_event* +-> xzoom* | +-> blctl* V +-> acpi3* uinput.ko +-> amixer | + .... V /dev/input/mice | V mouse events on X
Programs with `*' are included in this archive.
Following procedure is for kernel 2.6.11 + debian sarge environment. On another kernels or another distributions, slightly differ :)
$ find /lib/modules/`uname -r` -name sonypi.ko
options sonypi minor=250
# mknod /dev/sonypi c 10 250 # chmod 666 /dev/sonypi
find /lib/modules/`uname -r` -name uinput.ko
# mknod /dev/input/uinput c 10 223 # chmod 666 /dev/input/uinput
Make sure that following configuration is available in /etc/X11/XFree86-4.
Section "InputDevice" Identifier "Generic Mouse" Driver "mouse" Option "SendCoreEvents" "true" Option "Device" "/dev/input/mice" Option "Protocol" "ImPS/2" Option "Emulate3Buttons" "true" Option "ZAxisMapping" "4 5" EndSection ... Section "ServerLayout" ... InputDevice "Generic Mouse" ... EndSection
On top directory of extracted archives, do following. Programs are installed to /usr/local/bin.
$ make $ su # make install
Copy configs/dot_jdmouse_event to /.jdmouse_event, and edit to work your favorite action.
Load the needed drivers.
# modprobe sonypi # modprobe uinput
Then, run the program.
$ jdmouse &
An event interpreter for sonypi devices.
jdmouse [-d] [-s sonypi_device_file] \ [-e event_handler] \ [-u uinput_device_file] [-b 1|2|3]]
With this option, jdmouse dumps each event to stderr.
Specify sonypi defvice file. Default value is /dev/sonypi.
Specify event handler. Default value is /.jdmouse_event.
Specify uinput device file. Without this option, jdmouse does not convert from jogdial events to wheel mouse event, throws away them.
If you want to use jogdial events conversion of jdmouse, you must load sonypi driver with `useinput=0' option. Or your X will receive events twice, from sonypi and jdmouse, for an jogdial event.
Specify mouse button number for jogdial click. Number is same for X mouse button. 1 =left, 2 = center ( or wheel ), 3 = right. Default value is 2 (center).
The event hander is called by jdmouse with following system(2) command line.
program_name event_name sequence_number
An event handling program. This is specified by jdmouse command line with -e option, or default value /.jdmouse_event.
You can use any executable program, bash script or perl script, C executable and so on.
An event name from sonypi device driver. The name list is in /usr/include/linux/sonypi.h, which begins SONYPI_EVENT_ . On this command line API, `SONYPI_EVENT_' is omitterd. For example, when pressed Fn + F1 key, here is specified `FNKEY_F1'.
The sequence number for each event kind. They begin from 0.
For example, when pressed Fn + F1 key at first of running jdmouse, here is 0. Next, pressed Fn + F1 key, here is 1. Then, pressed Fn + F2 key, here is 0 not 2. Because each event kind has each counter.
You can use this number for cyclic command execution. For example, changing backlight brightness to max -> min -> max ...
There is an example script at configs/dot_jdmouse_event. Refer it.
A CAPTURE button on VAIO C1 (aka picturebook) generates events with each press / release. And it has deep / half press operation. It is too complicated for external handlers to interpret the sequence. So jdmouse converts the sequence as follows:
The sequence number on event handler API is unsigned 32 bit. So it has same problem with UNIX time. Overflow the counter, it will return to 0. But I think that it is hard for you to meet this bug, until you offer whole of your life to debugging jdmouse.
Numeric value of backlight brightness. You can specify from 0 to 255. 0 is most dark, 255 is most bright.
If no value is specified, print current value to stdout.
I was reported that on some VAIO series the brightest value was 100, not 255.
Zoom in / zoom out on X terminal
Specified `+' for zoom in. Or `-' for zoom out. If no option is specified, do zoom in.
This program implements Zoom in / zoom out functions with generating key events of `right ctrl'`right alt'`keypad + or -' via uinput driver. If you remapped these keys to another function with xmodmap command, this program will not work. Or at X configration, if you configured `not zoom in / out with these keys', also will not work.
Go to ACPI S3 (suspend) state.
This program works equivalent actiton with
# echo -n 3 >/proc/acpi/sleep
With installing setuid bit, normal user can execute this action. But in some case, this may be a security hole.
If so, consider using sudo management.