Revision: 72726
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 18, 2017 09:02 by xyzeugene
Initial Code
In case somebody is interested in answer I got it with this C program: #include <stdio.h> #include <gpm.h> int my_handler(Gpm_Event *event, void *data) { if(event->type & GPM_DOWN) { if(event->buttons & GPM_B_LEFT) system("./l.sh"); if(event->buttons & GPM_B_RIGHT) system("./r.sh"); if(event->buttons & GPM_B_MIDDLE) system("./m.sh"); } return 0; } int main() { Gpm_Connect conn; int c; conn.eventMask = ~0; /* Want to know about all the events */ conn.defaultMask = 0; /* don't handle anything by default */ conn.minMod = 0; /* want everything */ if(Gpm_Open(&conn, 0) == -1) printf("Cannot connect to mouse server\n"); gpm_handler = my_handler; while((c = Gpm_Getc(stdin)) != EOF) Gpm_Close(); return 0; } /*EOF*/
Initial URL
https://www.linuxquestions.org/questions/linux-software-2/capture-or-monitor-mouse-button-events-in-console-703018/
Initial Description
Install GPM using installer such as apt or dnf All you have to do is save code with mouse.c file name and compile it : gcc -o mouse mouse.c -lgpm and you got a "mouse" program that executes l.sh on left, r.sh on right and m.sh on middle mouse button click. You will also have to install gpm daemon (and run it) and libgpm. There is one issue, I can't get mouse wheel work whit libgpm. libgpm have very poor documentary so maybe someone knows how to read wheel events?
Initial Title
C Program to read mouse in console via GPM
Initial Tags
c, linux
Initial Language
Pascal