Balena Audio Block Custom PA Script


In order to properly use the Balena Audio block and actually output sound via my chosen Output i need to be able to set the following in a script.

set-card-profile 0 output:hdmi-stereo

I found this to work by cloning the audio block and adding this as suggested in the documentation to the start cmd:

COPY /usr/src/
CMD [ "pulseaudio", "--file /usr/src/" ]

My problem is now that i don’t know how to add a file to a balena block. Currently i have cloned the audio balena block manually and added this inside that block code. This works perfectly fine but isn’t really the solution i’m looking for because it means that i need to have a local copy of the block and can therefore not profit from the advantages of a balena block.

Can someone help me with adding a custom pulse audio script to the balena audio block?


Hi lukasknk

It sounds like you’ve managed to adapt the balena block to your needs by using a custom script, and now you’d like to reuse this block. What you can do is publish your custom version ( fork ) of the balena audio block as your own block. You can keep this new block private or make it public.

The overall steps are described in Develop with blocks - Balena Documentation

I’ve done them based on what you describe on my own, so you can use this as a reference.

First I forked the balena audio GitHub repo into my own org: GitHub - ramirogm/audio: Audio building block for balenaOS, based on pulseaudio.

I then added your script and edited the Dockerfile file, committed and pushed the changes.

The next step is to publish the changes. I went to my balena cloud dashboard and selected blocks on the left, created a new block, selected it, went to the “releases” page, and added a new one. This will show you that you need to run the following commands:

balena login
 balena push ramiro_gonzalez/audio

( obvs using your own organization )

If all goes well, you should see a happy unicorn at the end of the building process, and a new “release” on the block’s releases page on the dashboard.

You can then use this block on your docker-compose file using the “image reference” shown on the block Summary page. In my case, it’s

Last step: I made the block public as explained in Develop with blocks - Balena Documentation

Let me know if this helps!


1 Like

Here are some screenshots of the steps described above:

Create a block:

Block properties:

Adding a release

The release is building after executing balena push

1 Like

Thanks for that.

It wasn’t clear to me that the only way to adjust these things was to create a custom block. But that is good to know. Thanks for your help, this seemed to have been the solution i’m looking for.

Glad it helped! Let me know how it goes

Worked perfectly, thanks for your support.