Search code examples
linuxbashbackgroundkeypress

Detect Keypress in background Linux in c/bash


I want to detect a key combination like alt+g in an application that runs as a background process (other keypresses/combinations should be executed normally) , if the combination is pressed i want to block all keypresses and send them via serial to another linux pc instead of executing them. I cannot find a solution for detecting the key combination and recording the keys within a background process.

I'd prefer to use a bash script, but c is ok aswell. I just cant find a starting point. Any directions or help are appreciated.


Solution

  • Using Xlib I managed to fetch the keyboard Input http://www.x.org/releases/X11R7.7/doc/libX11/libX11/libX11.html