If you have a soundbar, no matter what name/model and it’s connected via Bluetooth, you might know the issue: You pair your Soundbar (or any Bluetooth Audio device, like headphones), it pairs successfully, you can hear music and you can use the device without any issue …
… until it decides to “sleep” (or power off) due to inactivity.
I have tried to look for a Linux solution using ALSA, Pulse Audio, even Pipewire – and .. nothing. There is no setting to do a simple “keep alive” to keep the device awake (if you know any native solution with these audio engines, please tell me)
Time for a “hack” solution, follow these steps:
- On your favorite Linux distro, install the tools: ffmpeg, play
- Lets create a simple 1-second silent MP3 file, with the following command: ffmpeg -f lavfi -i anullsrc=r=44100:cl=mono -t 1 -q:a 9 -acodec libmp3lame silent.mp3
- Move the silent.mp3 file to the Music folder
- Create a crontab entry using crontab -e (don’t do it as a root, just as your normal user)
- We’ll create an entry that will run every 30 minutes: */30 * * * * /usr/bin/play -q /home/hetz/Music/silent.mp3
(make sure it’s a one line!)
Now, every 30 minutes it should play this silent file, preventing the soundbar from going to sleep mode. If your device goes into sleep mode after 10 minutes, for example, then change the 30 to 10.