I run Raspberry pi's (rpi) in headless mode running Raspbian - a form of Debian. I would like to use the xev with xkeybinds approach (see Detect if mouse button is pressed, then invoke a script or command for details) as a general method to let USB devices control a headless rpi thru issuing shell commands.
Another method using X is to have a shell script running all the time with constant do while loop that pipes xinput --query-states to grep's loading the state of mouse buttons into variables that are conditionally tested and if true perform shell commands, like shutdown or mpc volume +2 to increase volume. This should work as I have script that outputs mouse states to the screen. Comments on this method are most welcome also.
My question is would this work?
Do I need to install all of X org apk's to get this to work? Which ones? Do I need an X daemon running all the time in order to have xkeybinds active all the time? How would I do this? Do I just have an active xterm all the time or run any X app daemon with the xvfb-run command.
If this works it would be a general method to allow thousands of USB HUID's to control headless rpi's without having to solder GPIO pins and use off the shelf devices.
All input is welcome.