I need working setup to do the following:
- Automaticaly connect some bluetooth audio devices (bluetooth speakers) on boot.
- On system startup (or by other cron background task) automatically play music on multiple audio device (including bluetooth from point 1).
Requirenment: Avoid interactive login to this system.
I have such setup on Ubuntu Desktop 22.04 using PulseAudio as system wide service. Setup is quite straightforward:
- Create unit file for system wide PulseAudio service /etc/systemd/system/pulseaudio.service to execute pulseaudio with "--system" flag:
[Unit]
Description=PulseAudio system server
[Service]
Type=notify
ExecStart=pulseaudio --daemonize=no --system --realtime --log-target=journal
Restart=on-failure
[Install]
WantedBy=multi-user.target
- Enable this unit:
sudo systemctl enable pulseaudio
- Add user account that will connect bluetooth device and play music to the following groups: pulse,pulse-access,audio
sudo usermod -a -G pulse,pulse-access,audio homeadmin
- Pair system with bluetooth audio device. This requires only once so i login to the system interactively and connect bluetooth speakers using Settings.
- Create script (/usr/local/bin/connect_audio.sh) that will connect bluetooth device and combine audio sinks as following:
bluetoothctl connect <blutooth device mac>
pactl load-module module-combine-sink
- Shedule script from point 5 and audio player using cron:
@reboot /usr/local/bin/connect_audio.sh; mpg123 <path to mp3>
But i have no success to migrate this setup to Ubuntu 24.04. It is not working. After install PulseAudio and make it as system-wide service on 24.04 (as described above) i can't get to make bluetooth audio devices available for user as system audio device without interactive login. It looks like pipewire is used as audio subsystem for Ubuntu Desktop 24.04 and it prevents this.
What i have tried to do on 24.04:
- To find and use config to run pipewire system wide same as PulseAudio. No working solution with bluetooth support found. It looks like it is not possible and not supported at this time. Some discussions here: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1610
- To disable pipewire (How to uninstall pipewire and go back to pulseaudio), install Pulse audio and then setup PulseAudio as system-wide service (as described above). It looks like it is not posible to disable pipewire completely because it is part of Desktop (gdm) now.
Please help me to make working setup on Ubuntu Desktop 24.04 using pipewire or PulseAudio.
UPD. The only two working options i found to workaround this issue:
- To use Ubuntu Server 24.04 instead of Desktop. It has no gdm (graphical interface) and thus no pipewire installed. In this case bluetooth and audio does not work "out-of-box" and requires extra step for configuration.
- To use Ubuntu Desktop but enable auto-login to user account with bluetooth speakers connected. This is the only case when bluetooth speakers start to be available for user as audio device in a system. But in this case my requirenment does not met.