I have a problem with configuring ALSA. The ALSA uses asound.conf file that lies in $SNAP/etc/asound.conf, but sometimes during application running I need to modify it to be able to record sound from microphone. Unfortunately, it’s not possible due to $SNAP/etc being read-only filesystem. So I thought I’ll create asound.conf in $SNAP_DATA and symlink in $SNAP/etc that will point to this file.
How to do it? I tried layouts and installation hook, but nothing works.
ogra
August 2, 2022, 10:37am
2
well, layouts and a hook are the usual way to make this work … this can be the configure hook or an install hook.
the latter only gets executed at install of the snap though, i personally tend to use the configure hook here, like:
#! /bin/sh
[ -e $SNAP_DATA/asound.conf ] || cp $SNAP/etc/asound.conf $SNAP_DATA/
[...]
further configure stuff here ...
[...]
and then have a layout like:
layout:
/etc/asound.conf:
bind-file: $SNAP_DATA/asound.conf
(might be better to use “symlink” instead of “bind-file”, you should test both)
@ogra that’s what I tried, nothing worked and I have no idea what to do now.
Do you have somewhere a working example with symlinks? I was not able to create a working symlink no matter how I tried.
Can you tell me how bind-file is supposed to work? Is it similar to symlinks i.e. when you have:
/etc/hello.conf:
bind-file: $SNAP_DATA/etc/hello.conf
Is it similar to symlinking it from /etc/hello.conf
to $SNAP_DATA/etc/hello.conf
?
I was not able to do anything on my Raspberry Pi OS. Maybe I’m doing something wrong.
This is my example repository that I tried to make work: https://github.com/dloranc/snap-test
Can you take a look, please?
You would want to do something like:
layout:
$SNAP/etc/asound.conf:
symlink: $SNAP_DATA/etc/asound.conf
Though when verifying that it works or not, you will need to see the environment from the snap perspective i.e. shell into the snap such as:
snap run --shell your_app