I have notebook with this weird ASUS keyboard, where for some reasons in place of the End
key there is Power Off
(Pictures). I want to undo the damage and let my Ubuntu Linux interpret this key as End
.
I know how to intercept the Power Off
using acpid and let it fire any command upon the keypress I want, as a root.
I would like it to emulate a scan codes 0xe0 0x4f
followed by 50ms pause and then 0xe0 0xcf
.
How to emulate a low-level keypress via scancode on modern Notebook and Linux?
I tried writing the scancodes to the port using the following program
/* gcc -O2 -s -Wall -osend_to_keyboard main.c */
#include <stdlib.h>
#include <unistd.h>
#include <sys/io.h>
int main(int argc, char *argv[]) {
int i;
ioperm(0x60, 3, 1);
for (i = 1; i < argc; i++) {
int x = strtol(argv[i], 0, 16);
usleep(300);
outb(x, 0x60);
}
return 0;
}
but nothing happened. Maybe the code doesn't work for my keyboard. I never did anything so low-level on Linux, so I lack proper experience.
For those of you who are laterally thinking: I don't want to emulate keypresses on X only using e.g. xdotool. ;-)