How to remap right alt to control on ubuntu
Jump to navigation
Jump to search
$ cat /etc/interception/udevmon.yaml - JOB: intercept -g $DEVNODE | ralt2ctrl | uinput -d $DEVNODE DEVICE: EVENTS: EV_KEY: [KEY_RIGHTALT]
$ cat ~/forks/ralt2ctrl/ralt2ctrl.c #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <linux/input.h> #define DEBUG 1 int read_event(struct input_event *event) { return fread(event, sizeof(struct input_event), 1, stdin) == 1; } int write_event(const struct input_event *event) { if (fwrite(event, sizeof(struct input_event), 1, stdout) != 1) { exit(EXIT_FAILURE); } } int main() { struct input_event input; setbuf(stdin, NULL); setbuf(stdout, NULL); while (read_event(&input)) { // printf("read event. %d is EV_MSC, %d is EV_KEY\n", EV_MSC, EV_KEY); // printf("read event %d\n", input.type); if (input.type == EV_MSC && input.code == MSC_SCAN) { continue; } if (input.type == EV_KEY && input.code == KEY_RIGHTALT) { // printf("ok u did it"); // fprintf(stderr, "GOT RIGHTALT"); struct input_event lctrl = {.type = EV_KEY, .code = KEY_RIGHTCTRL, .value = input.value}; write_event(&lctrl); continue; } write_event(&input); } }
gcc ralt2ctrl.c -o ralt2ctrl && sudo cp ralt2ctrl /usr/local/bin/ sudo add-apt-repository ppa:deafmute/interception sudo apt install interception-tools sudo systemctl start udevmon.service
TODO try this all from scratch... I don't trust it.
TODO clean up c code