07-28-2020, 01:21 PM
(This post was last modified: 08-06-2020, 10:40 AM by CyberSeb.
Edit Reason: Improved script
)
Hi @fernando_c_m,
oh thanks for your feedback. I don't know how this error has crept in! I've fixed the original post.
Here's an updated version of bluetooth.sh:
Notice that the script now tries to reconnect the bluetooth device after restarting the bluetooth service. It also tries to setup an automatic bluetooth reconnection (you need to edit /etc/pulse/default.pa first, see script).
This sort of works, but is not perfect! Sometimes there is a loud hum after reconnecting, this has happend with both of my bluetooth headsets. Using delays in the script could potentially help.
What I haven't figured out yet is how to get the buttons on the headsets working. According to https://wiki.archlinux.org/index.php/Blu...a_controls, this should work with "mpris-proxy". The tool recognizes the bluetooth connections and the players (I've tried Lollypop and Rhythmbox), but it does not work.
Cheers,
Sebastian
oh thanks for your feedback. I don't know how this error has crept in! I've fixed the original post.
Here's an updated version of bluetooth.sh:
Code:
#!/bin/bash
# Note: Bluetooth headset must be connect when running this script.
# Enable auto connection of the bluetooth device (add "load-module module-switch-on-connect" to /etc/pulse/default.pa first):
MACADDR=`pactl list cards | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'`
bluetoothctl trust $MACADDR
# Increase latency:
BLUEZCARD=`pactl list cards short | egrep -o bluez.*[[:space:]]`
SNDDEVICE=`pactl list | grep '\-output:' | head -n1 | cut -d ":" -f1 | xargs`
pactl set-port-latency-offset $BLUEZCARD $SNDDEVICE 100000
# Restart bluetooth:
sudo service bluetooth restart
# Reconnect:
bluetoothctl connect $MACADDR
# Show current settings:
pactl list | grep -Pzo '.*bluez_card(.*\n)*'
Notice that the script now tries to reconnect the bluetooth device after restarting the bluetooth service. It also tries to setup an automatic bluetooth reconnection (you need to edit /etc/pulse/default.pa first, see script).
This sort of works, but is not perfect! Sometimes there is a loud hum after reconnecting, this has happend with both of my bluetooth headsets. Using delays in the script could potentially help.
What I haven't figured out yet is how to get the buttons on the headsets working. According to https://wiki.archlinux.org/index.php/Blu...a_controls, this should work with "mpris-proxy". The tool recognizes the bluetooth connections and the players (I've tried Lollypop and Rhythmbox), but it does not work.
Cheers,
Sebastian