1) in rc.local or somewhere in startup scripts add: /usr/bin/setkeycodes e058 140
2) compile this little C program"keycheckd" (gcc -o keycheckd keycheckd.c) and place the compiled binary in /usr/local/bin/, and chown 4755 keycheckd
3) In your X desktop session's startup script do (must be started from w/n X desktop, NOT startup or console!):
Code: Select all
xset -r 138 -r 140 -r 146 -r 148
keycheckPid=`pidof keycheckd`;
if [["X$keycheckPid" =="X" ]]; then
/usr/bin/nice -n 10 /usr/local/bin/keycheckd &
fi
Code: Select all
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <linux/input.h>
#include <string.h>
#include <stdio.h>
/*
JWT:THIS DAEMON PGM WATCHES THE KEYBOARD FOR PRESSES OF THE SPECIAL HP ELITEBOOK 8440P"TOGGLE-KEYPAD"
KEY WHICH X (xev, xbindkey & FRIENDS REFUSE TO SEE AFTER THE 1ST PRESS PER REBOOT) AND INVOKES THE
COMMAND TO TOGGLE THE TOUCHPAD (AS IT WAS DESIGNED TO DO). X DOESNPT LIKE THIS SPECIAL KEY B/C IT
ONLY SENDS A"KeyPressed" EVENT W/NO CORRESPONDING"KeyReleased" EVENT. IT WORKS LIKE OTHER"LED"DED
KEYS SUCH AS CAPSLOCK AND NUMLOCK! THE INITIAL STATE IS"BLUE" (TOUCHPAD ON), FIRST PRESS SENDS
KEYCODE 140 (148 TO xbindkeys) AND SWITCHES THE LED TO"ORANGE". NEXT PRESS SENDS KEYCODE 138 (146)
AND SWITCHES THE LED BACK TO"BLUE". SUBSEQUENT KEYPRESSES ALTERNATE BETWEEN THESE TWO STATES.
I STOLE THIS PGM. FROM HERE: http://stackoverflow.com/questions/20943322/accessing-keys-from-linux-input-device
I MODIFIED IT TO ONLY CARE A/B THESE TWO KEYCODES. NOTE: I HAD TO ADD"setkeycodes e058 140" TO
rc_local.pl WHEREAS THE OTHER ONE (138) WAS ALREADY RECOGNIZED BY THE KERNEL. THIS PROGRAM SHOULD BE
STARTED THE FIRST TIME AFTERSTEP STARTS UP (.afterstep/autoexec)
*/
int main(void)
{
const char *dev ="/dev/input/by-path/platform-i8042-serio-0-event-kbd";
struct input_event ev;
ssize_t n;
int fd;
fd = open(dev, O_RDONLY);
if (fd == -1) {
fprintf(stderr,"Cannot open %s: %s.\n", dev, strerror(errno));
return EXIT_FAILURE;
}
while (1) {
n = read(fd, &ev, sizeof ev);
if (n == (ssize_t)-1) {
if (errno == EINTR)
continue;
else
break;
} else
if (n != sizeof ev) {
errno = EIO;
break;
}
if (ev.type == EV_KEY && ev.value >= 0 && ev.value <= 2) {
/* printf("0x%04x (%d)\n", (int)ev.code, (int)ev.code); */
if ((int)ev.code == 138) {
/* TURN ON TOUCHPAD: */
/* printf("--138: turn touchpad ON!\n"); */
system ("/usr/bin/synclient TouchpadOff=0");
} else if ((int)ev.code == 140) {
/* TURN OFF TOUCHPAD: */
/* printf("--140: turn touchpad off!\n"); */
system ("/usr/bin/synclient TouchpadOff=1");
}
}
}
fflush(stdout);
fprintf(stderr,"%s.\n", strerror(errno));
return 0;
}
Hope someone else finds this hack useful!
Jim