Skip to content

Instantly share code, notes, and snippets.

@productiveme
Created December 21, 2020 10:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save productiveme/8b39f5799fcb3e5681d0ef985884fb51 to your computer and use it in GitHub Desktop.
Save productiveme/8b39f5799fcb3e5681d0ef985884fb51 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment