EDIT: Previous answer was distro dependent and had a syntax error. I have replaced it with the following instructions.
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):
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).