jrouleau / bluetooth-autoconnect

A linux command line tool to automatically connect to all paired and trusted bluetooth devices.
MIT License
213 stars 41 forks source link

Only attempts to connect once at startup #4

Closed skippa closed 4 years ago

skippa commented 4 years ago

I'm having an issue - bluetooth-autoconnect only attempts to connect once at startup, then when it fails it doesn't try again. It seems to only be when the mouse it already on from a previous session. If I turn the mouse off, then turn it on after bootup, it connects automatically. It will also connect if I put it into pair mode, and manually type bluetooth-autoconnect -v at startup...

Is this package designed to only attempt to connect once to a device, then if it fails it doesn't retry? If so, can I change this functionality?

gitthangbaby commented 4 years ago

stopped working when i added a bluetooth mouse. have to run this repeatedly systemctl --user start pulseaudio-bluetooth-autoconnect.service as this service doesn't run. also after disconnecting the audio returns to a wrong output, not the previous output.

jrouleau commented 4 years ago

@skippa That is by design. The daemon mode only attempts to connect to paired and trusted bluetooth devices when an adapter is powered on. This package does not constantly probe devices as that would have a huge impact on power consumption. It is generally up to each device to announce itself when it is powered on.

If you want or need a continuous probe functionality, you could create a cron or systemd timer to run either bluetooth-autoconnect for all devices, or just bluetoothctl connect <device_mac> for a specific device, but repeatedly attempting to connect will do little good if your device isn't responding to connection attempts. Behind the scenes, all this script is really doing is running bluetoothctl connect <device_mac> for each device that is paired and trusted, so if running that command manually doesn't work, there's little this script can do to help.

In the case of my bluetooth mouse, it goes to sleep immediately after being disconnected and won't respond to connection attempts, but it wakes up, announces itself, and connects automatically after simply moving it. If I wake it up before my system boots, then bluetooth-autoconnect triggers the connection attempt instead.

@gitthangbaby You can enable the pulseaudio helper service with systemctl --user enable pulseaudio-bluetooth-autoconnect so you don't have to start it manually every boot. That service is a simple one-shot service that runs bluetooth-autoconnect which in turn, really just runs bluetoothctl connect <device_mac> for each device that is trusted and paired. If your device keeps disconnecting and you have to keep reconnecting repeatedly, then that has nothing to do with this script and you will need to troubleshoot your bluetooth / bluez configuration.

For example, my headset doesn't work correctly if Bluez is operating in LE (Low-Energy) mode so I have ControllerMode = bredr set in my /etc/bluetooth/main.conf to prevent this. Perhaps that may work for you, but it is beyond the scope of what I can support here.

This package has no influence or control over what audio output devices your system uses. That is between you and pulseaudio.