jrouleau / bluetooth-autoconnect

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

Delayed restart after suspend/sleep #12

Closed costis-t closed 2 years ago

costis-t commented 2 years ago

I have a Bluetooth speaker as a slave in a Master/Slave power strip with the main system as a Master. This helps enormously with energy savings. When the system wakes up, the service needs to restart with delay so the just powered on Bluetooth speaker can reconnect to the system. One way to solve the problem is by creating an executable reconnect_to_bluetooth.sh at /lib/systemd/system-sleep:

#!/bin/sh
case $1/$2 in
  pre/*)
    echo "Other"
    ;;
  post/*)
    sleep 40 # Because Bluetooth speaker turns on in about 30 seconds
    systemctl restart bluetooth-autoconnect.service
    ;;
esac
costis-t commented 2 years ago

Just opened it for future reference.

jrouleau commented 2 years ago

Restarting the daemon is a bit overkill. A one off bluetooth-autoconnect should also work.