Connect to Bluetooth speaker at login?

I have Bluetooth speakers which I would like to automatically connect to when I log in to my desktop computer. What is a reliable way to accomplish this on Fedora Workstation 33 please?

I can manually connect to the speakers using GNOME’s bluetooth settings GUI or execute bluetoothctl connect C8:84:47:XX:XX:XX in terminal (with my true MAC address, redacted here). The bluetooth speakers are AC powered and have power-saving features disabled - they are always on and ready to connect.

A systemd user service seems to be one option, however I can’t get this method to work yet. Here’s what I have tried so far.

I have a file ~/.config/systemd/user/bluetooth-soundbar.service with the following contents:

Description=Connect to soundbar at login

ExecStart=bluetoothctl connect C8:84:47:XX:XX:XX


I enabled and started the new service with systemctl --user enable bluetooth-soundbar.service && systemctl --user start bluetooth-soundbar.service

I tried adding BindsTo=bluetooth.service and/or to the [Unit] section as recommended in the documentation, however these do not appear to have any effect. I also tried with ExecStart=/bin/sh -c "bluetoothctl connect C8:84:47:XX:XX:XX" (instead of using the command by itself).

/etc/bluetooth/main.conf has AutoEnable=true by default, and systemctl status bluetooth shows bluetooth running automatically and by default after login.

The Arch wiki mentions adding “load-module module-switch-on-connect” to /etc/pulse/, however when I tried this I had no sound or sound settings after rebooting so reverted to the default file.

What am I missing please? Can this be accomplished, and is systemd the correct tool for something like this?


Check the journal for errors:

journalctl --no-pager --user bluetooth-soundbar.service

Perhaps the action requires to utilize D-Bus or some environment variables.

You can also try the DE autostart:

Thank you, adding a .desktop file in ~/.config/autostart finally worked. I guess the systemd service method was too complicated.

I checked the journal for errors and got the message Failed to add match 'bluetooth-soundbar.service': Invalid argument Not important now, it’s working by another method.

If anyone else wants to do this, use this template for your .desktop file, to be placed in ~/.config/autostart (adapted for your device MAC):

[Desktop Entry]
Name=Bluetooth Soundbar
Exec=bluetoothctl connect C8:84:47:XX:XX:XX
1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.