BT is enabled at startup. This is nice. But it will not autopair/connect to a device, even if it is once paired and get status "trusted". I can connect to a Speaker with the tool by selecting device, and "connect to audio output". How can this done automatically on boot? I can do this also with "bluetoothctl" and than "connect ", but this is interactive, seems not scriptable.
And second step is, that BT becomes default audio sink.
Isn't that all an ordinary use case?
(I found some pages here, most are outdated.) Autoconnecting Bluetooth Devices: load-module module-switch-on-connect doesn't work for me.
I also installed bt-autoconnect. But several issues: - it didn't foun the BT-Adapter - Button Audio-Setting does just nothing - Save and quit doesn't just nothing
Try
bluetoothctl
command.If you then enter
help
, you'll see the commands to be used.Try, it worked for me.
For automatic connect to Audio Sink you can add the following line in
/etc/rc.local
:Update the address. You can verify from command line by:
In my case
sleep 6
is enough - but maybe on your computer it has to be increased to allow other bluetooth connection steps to be fully completed.Generally with
&
sign at the end you will start process which will be executed in 6sec not blocking next processes starting normal bluetooth connection functions. If the rc.local is not existing (it was in my case) you can create it or to initiate at startup with other file.For the second part (auto switch to BT speaker as a sink) I found a solution. Has been already posted here:
BUT: How can the BT server automatically pair with the speaker, as soon as it is available? HELP!
Edit: found a (not the best imho) solution for the first question:
BUT: Even better would be that this works without this MAC for all ever devices that has been connected and trusted.
I wrote a simple script that will keep reconnecting the device when you reboot your PC or when the device toggles bluetooth status or lose a signal for a while.
echo "devices" | bluetoothctl | grep Device
~/.bt-autoconnect.sh
chmod +x ~/.bt-autoconnect.sh
echo "~/.bt-autoconnect.sh &" >> "~/.xprofile"
In Ubuntu sound-problems are due to installed drivers. If this speaker is the newest and most trendiest hardware, you have no good chances and would have to wait 2 to 8 months until driver is present at Linux Community. But you could try to install following packages in terminal :
Then switch on bluetooth and see if your speaker is supported :
Good luck or be patient for at maximum 8 months.
In my case this Script works (I tried all setting but not work for me,Step 5 from Here)
Python script on GitHub called bluetooth-autoconnect. It’s a python script that automatically connects to all paired and trusted Bluetooth devices. However, the script is not available to install directly on Flatpak or Apt repository. Hence, we need to manually download and configure the service.
download the zip file from GitHub or use the following command to clone the repository to your home directory.
Now that we have the repository downloaded we need to move the service and scripts to their respective location before we start the service. In systemd architecture:-
Once, we have successfully copied the service to the respective directories, let’s enable and start the service. To do that, use the following command.
Now remove and reconnect and Done.