Skip to content

Instantly share code, notes, and snippets.

@rscircus
Forked from productiveme/fixmouselag.sh
Last active August 25, 2023 06:55
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rscircus/ddafae0784e7e06e8769b67095c6a5f2 to your computer and use it in GitHub Desktop.
Save rscircus/ddafae0784e7e06e8769b67095c6a5f2 to your computer and use it in GitHub Desktop.
Fix bluetooth mouse lag on Ubuntu
#!/bin/bash
MouseIdentifierString="Mouse"
writeOpts() {
sudo cat <<'EOF' | sudo tee -a /var/lib/bluetooth/$1/$2/info
[ConnectionParameters]
MinInterval=6
MaxInterval=7
Latency=0
Timeout=216
EOF
sudo systemctl restart bluetooth
}
eachDev() {
if sudo grep -q $MouseIdentifierString /var/lib/bluetooth/$1/$2/info
then
if ! sudo grep -q "ConnectionParameters" /var/lib/bluetooth/$1/$2/info
then
writeOpts $1 $2
fi
fi
}
eachCtrl() {
sudo ls -1 /var/lib/bluetooth/$1 | egrep -v "(cache|settings)" | while read dev; do
eachDev $1 $dev
done
}
ls -1 /var/lib/bluetooth | while read ctrl; do
eachCtrl $ctrl
done
@OussamaFasca
Copy link

Works like a charm

@lkuschnig
Copy link

Awesome, thank you

@jpalmonacid
Copy link

@rscircus Thanks for sharing. I liked how you use both while and read commands instead of a for loop and command substitution. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment