#!/bin/sh

# Script to Disable Mouse Acceleration (for dwm)

# dmenu prompt to select the right device (using xorg-xinput)
deviceID=$(xinput | grep -B1000 "Virtual core keyboard" | preconv | cut -d' ' -f5-  |\
sed '$ d; /^$/d;' | grep -v "master pointer" | rev | cut -d' ' -f5- | rev |\
sed 's/\[slave//g;' | tr '\t' '    ' | dmenu -i -l 30 | awk '{print $NF}' | sed 's/id=//g')

[ -z "$deviceID" ] && exit 1

# disable the mouse acceleration (using xorg-xinput)
xinput --set-prop "$deviceID" 'libinput Accel Speed' 0
xinput --set-prop "$deviceID" 'libinput Accel Profile Enabled' 0, 1

# set the mouse speed (using xorg-xset)
xset mouse 1 0 &
