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

Add option for daemon to make periodic atempts to reconnect #21

Closed rparkins999 closed 3 months ago

rparkins999 commented 4 months ago

At present the script only tries to reconnect if it detects a new adapter. If a connected device is a phone being carried by its owner, the connection will be dropped if the owner walks away from the computer and stays out of bluetooth range for a while. It would be nice to automatically reconnect the phone when it comes back into range. In the meantime this crontab entry might help

Force bluetooth to reconnect my phone if connection lost because I walked out of range

runs every minute

- * root /etc/bluetooth/bluetooth-autoconnect

rparkins999 commented 4 months ago

Oops, markdown thinks # is a heading. The crontabcode should be # Force bluetooth to reconnect my phone if connection lost because I walked out of range # runs every minute - * root /etc/bluetooth/bluetooth-autoconnect

jrouleau commented 3 months ago

This has come up in the issues a few times. Please review the closed issues for more detailed discussions on this matter, but the simple answer is: it can't know when a device is brought back into range and at least one of the devices would need to continually scan / probe. This can trivially be solved with a cron job like yours above. If you only want to scan for a specific device with a known mac address you could instead use bluetoothctl connect <mac_address> which will no-op (except for log spam) if the device is already connected.

P.S. you can open a code block with triple backticks. E.g. but without the leading backslashes:

\```
# code here
\```