Created
May 23, 2019 12:08
-
-
Save gerritwalther/fd43643335f83ca0cd69c75dfa320b19 to your computer and use it in GitHub Desktop.
Toggle mouse speed between two values using ratbag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SPEED_DEFAULT=1000 | |
SPEED_OTHER=400 | |
if ! [ -x "$(command -v ratbagctl)" ]; then | |
echo 'Error: ratbag is not installed.' >&2 | |
echo 'Install with "pacman -S libratbag" or "apt-get install ratbagd"' | |
exit 1 | |
fi | |
MOUSENAME=`ratbagctl | awk -F: '{ print $1 }'` | |
echo "Using mouse '$MOUSENAME' for the script." | |
DPI=`ratbagctl $MOUSENAME dpi get | awk -Fd '{ print $1 }'` | |
echo "Currently '$DPI' DPI are set" | |
if (( $DPI == $SPEED_OTHER )); then | |
echo "Setting DPI to $SPEED_DEFAULT" | |
ratbagctl $MOUSENAME dpi set $SPEED_DEFAULT | |
else | |
echo "Setting DPI to $SPEED_OTHER" | |
ratbagctl $MOUSENAME dpi set $SPEED_OTHER | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment