Man bekommt Mausbewegungen auch mit xinput:
xinput test <deviceid>
Das würde bei einem Mouseevent nach stdout schreiben, das einzige Problem ist dass xinput stdout nicht flusht, man es also nicht wirklich pipen kann. Ich habe mal eine simples Programm zusammengehackt dass bei Mousebewegung die Zeit und die x- und y-Koordinate nach stdout schreibt:
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/extensions/XInput.h>
int
register_device(Display *dpy, XDeviceInfo *info)
{
XDevice *device;
int type;
XEventClass klass;
device = XOpenDevice(dpy, info->id);
if (device == NULL)
{
fprintf(stderr, "Cannot open device %lu\n", info->id);
return 1;
}
DeviceMotionNotify(device, type, klass);
if (XSelectExtensionEvent(dpy, DefaultRootWindow(dpy), &klass, 1) != 0)
{
fprintf(stderr, "Cannot select extension event\n");
return 1;
}
return 0;
}
int main (int argc, char **argv)
{
Display *dpy;
Atom mouse_atom;
XEvent e;
XDeviceInfo *all_devices;
int n_devices;
dpy = XOpenDisplay(NULL);
if (dpy == NULL)
{
fprintf(stderr, "Cannot open display\n");
return 1;
}
mouse_atom = XInternAtom(dpy, XI_MOUSE, False);
all_devices = XListInputDevices(dpy, &n_devices);
for (int i=0; i<n_devices; i++)
{
if (all_devices[i].type == mouse_atom)
{
register_device(dpy, &all_devices[i]);
}
}
while (1)
{
XNextEvent(dpy, &e);
XDeviceMotionEvent *motion = (XDeviceMotionEvent *) &e;
printf("%lu %d %d\n", motion->time, motion->x, motion->y);
fflush(stdout);
}
}
Denkbar wäre es auch das als daemon laufen zu lassen und noch einen Client zu
schreiben der dann nur die Zeit der letzten Mausbewegung beim daemon abfragt.