How to make a program that finds id's of xinput devices and sets xinput some settings
You can do something like the following.
if [ "$SEARCH" = "" ]; then
exit 1
fi
ids=$(xinput --list | awk -v search="$SEARCH" \
'$0 ~ search {match($0, /id=[0-9]+/);\
if (RSTART) \
print substr($0, RSTART+3, RLENGTH-3)\
}'\
)
for i in $ids
do
xinput set-prop $i 'Device Accel Profile' -1
xinput set-prop $i 'Device Accel Constant Deceleration' 2.5
xinput set-prop $i 'Device Accel Velocity Scaling' 1.0
done
So with this you first find all the IDs which match the search pattern $SEARCH
and store them in $ids
.
Then you loop over the IDs and execute the three xinput
commands.
You should make sure that $SEARCH
does not match to much, since this could result in undesired behavior.
If the device name is always the same, in this case Logitech G700 Laser Mouse
, you can search for matching device IDs by running
xinput list --id-only 'Logitech G700 Laser Mouse'
My 2 cents for a Logitech Gaming Mouse G502
#!/bin/sh
for id in `xinput --list|grep 'Logitech Gaming Mouse G502'|perl -ne 'while (m/id=(\d+)/g){print "$1\n";}'`; do
# echo "setting device ID $id"
notify-send -t 50000 'Mouse fixed'
xinput set-prop $id "Device Accel Velocity Scaling" 1
xinput set-prop $id "Device Accel Constant Deceleration" 3
done