How to re-enable bluetooth after system resume

I share a problem with a lot of people: The bluetooth on my laptop stops working after awakening from suspend state and sometimes doesn't even activate at boot.

The problem is, that firmware needs to be uploaded to the device, and this sometimes failes during the boot/wakeup process.

One solution is as simple as unsatisfying:

Re-enable bluetooth

Once the machine is fully booted/resumed, it is sufficient to reload the btusb module to reupload the firmware to the device and thereby re-enabling bluetooth services:

notify-send "Restarting Bluetooth..."
sleep 2
sudo /usr/bin/rmmod btusb
sleep 3 
sudo /usr/bin/modprobe btusb

Just execute ${HOME}/bin/ at the command line, after a suspended session is resumed.

It would be nice to automate that.

Enable a systemd instance for user

To enable a systemd instance that respects services and targets defined in ${HOME}/.config/systemd/user, execute

sudo loginctl enable-linger $USER

The extra-instance will be started at boot, to the best of my knowledge – I don't know what service to restart to enable this behaviour without a reboot of the system.

A service definition to run after suspend

Description=User resume actions