Is there any way to get mouse button state from bash? Xdotool can only get mouse location. I'd like to set something up where I can define a rule where when a mouse button is pressed, a script can get executed.
Detect if mouse button is pressed, then invoke a script or command
bash;mouse
xinput --query-state <mouse_id>This give you a state for all mouse buttons, that looks like this:2 classes :ButtonClass    button[1]=up    button[2]=up    button[3]=up    button[4]=up    button[5]=up    button[6]=up    button[7]=up    button[8]=up    button[9]=up    button[10]=up    button[11]=up    button[12]=up    button[13]=up    button[14]=up    button[15]=up    button[16]=upValuatorClass Mode=Relative Proximity=In    valuator[0]=313    valuator[1]=667    valuator[2]=-20The mouse_id can be obtained from:xinput --listHere is a little mouse button watcher script:#!/bin/bashMOUSE_ID=$(xinput --list | grep -i -m 1 'mouse' | grep -o 'id=[0-9]\+' | grep -o '[0-9]\+')STATE1=$(xinput --query-state $MOUSE_ID | grep 'button\[' | sort)while true; do    sleep 0.2    STATE2=$(xinput --query-state $MOUSE_ID | grep 'button\[' | sort)    comm -13 <(echo $STATE1) <(echo $STATE2)    STATE1=$STATE2doneYou may need to change MOUSE_ID detection string('mouse') to something else.