C
public c v1 · immutable#include <stdio.h>#include <stdlib.h>#include <linux/input.h>#include <fcntl.h>/* this is a quick hack to catch the hx4700's power off key */int main (int argc, char *argv[]) { FILE *f; struct input_event e; int fd; if (!(f = fopen ("/dev/input/event0", "r"))) exit (1); do { if (fread (&e, sizeof(e), 1, f) != 1) continue; if ((e.type == EV_KEY) && (e.code == KEY_POWER) && (e.value == 1)) system("apm -s"); } while (1); fclose (f); return 0;}