There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

Para_lyzed , (edited )

While trying to test this on my system, I came across a few issues. I found a more modern and standardized way to check for login after sleep, and have updated my previous comment with a new script. I have new instructions though that are more comprehensive that you can follow.

Create 2 files bluetooth-reconnect.sh and bluetooth-reconnect.service. Using your favorite text editor, edit these files so they will contain the following:

bluetooth-reconnect.sh


<span style="color:#323232;">#!/bin/bash
</span><span style="color:#323232;">
</span><span style="color:#323232;">gdbus monitor -y -d org.freedesktop.login1 |
</span><span style="color:#323232;">  (while read x; do
</span><span style="color:#323232;">    if echo "$x" | grep -q "{'LockedHint': <false>}"; then
</span><span style="color:#323232;">      bluetoothctl connect A1:11:22:3A:CD:F1
</span><span style="color:#323232;">    fi
</span><span style="color:#323232;">  done)
</span>

bluetooth-reconnect.service


<span style="color:#323232;">[Unit]
</span><span style="color:#323232;">Description=Reconnect Bluetooth after waking from sleep
</span><span style="color:#323232;">After=default.target
</span><span style="color:#323232;">
</span><span style="color:#323232;">[Service]
</span><span style="color:#323232;">Type=simple
</span><span style="color:#323232;">ExecStart=/usr/local/bin/bluetooth-reconnect.sh
</span><span style="color:#323232;">
</span><span style="color:#323232;">[Install]
</span><span style="color:#323232;">WantedBy=multi-user.target
</span>

Open a terminal in whatever location you created them (you can right click in your file manager and open in terminal, or use cd to navigate). Now move them to the correct locations (you will need sudo privilege for this):


<span style="color:#323232;">sudo mv bluetooth-reconnect.sh /usr/local/bin/bluetooth-reconnect.sh
</span><span style="color:#323232;">sudo mv bluetooth-reconnect.service /etc/systemd/system/bluetooth-reconnect.service
</span>

Make the script executable:


<span style="color:#323232;">sudo chmod +x /usr/local/bin/bluetooth-reconnect.sh
</span>

Enable and start the service:


<span style="color:#323232;">sudo systemctl enable bluetooth-reconnect.service
</span><span style="color:#323232;">sudo systemctl start bluetooth-reconnect.service
</span>

Check to make sure the service started correctly (the “Active:” field should say “active (running)” in green).


<span style="color:#323232;">sudo systemctl status bluetooth-reconnect.service
</span>

This should now do everything automatically. This has been tested and is working on my Fedora Workstation system (uses GNOME). This should be distro independent, unlike my previous answer (and also without the syntax error I had in my initial submission).

To uninstall:


<span style="color:#323232;">sudo systemctl stop bluetooth-reconnect.service
</span><span style="color:#323232;">sudo systemctl disable bluetooth-reconnect.service
</span><span style="color:#323232;">sudo rm /etc/systemd/system/bluetooth-reconnect.service
</span><span style="color:#323232;">sudo rm /usr/local/bin/bluetooth-reconnect.sh
</span>
  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines