Hi Paresh, 

On 11:33-20260123, Paresh Bhagat via lists.yoctoproject.org wrote:
> - Add set-audio-defaults.sh script for audio setup
> - Add set-audio-defaults.service systemd service
> - Add wireplumber_0.5.1.bbappend recipe extension
> 
> Signed-off-by: Paresh Bhagat <[email protected]>

Thanks for your patch!

> ---
>  .../wireplumber/set-audio-defaults.service    | 14 +++++++++
>  .../wireplumber/set-audio-defaults.sh         | 30 +++++++++++++++++++
>  .../wireplumber/wireplumber_0.5.1.bbappend    | 25 ++++++++++++++++
>  3 files changed, 69 insertions(+)
>  create mode 100644 
> meta-arago-distro/recipes-multimedia/wireplumber/wireplumber/set-audio-defaults.service
>  create mode 100755 
> meta-arago-distro/recipes-multimedia/wireplumber/wireplumber/set-audio-defaults.sh
>  create mode 100644 
> meta-arago-distro/recipes-multimedia/wireplumber/wireplumber_0.5.1.bbappend
> 
> diff --git 
> a/meta-arago-distro/recipes-multimedia/wireplumber/wireplumber/set-audio-defaults.service
>  
> b/meta-arago-distro/recipes-multimedia/wireplumber/wireplumber/set-audio-defaults.service
> new file mode 100644
> index 00000000..18881553
> --- /dev/null
> +++ 
> b/meta-arago-distro/recipes-multimedia/wireplumber/wireplumber/set-audio-defaults.service
> @@ -0,0 +1,14 @@
> +[Unit]
> +Description=Set PipeWire Default Audio Devices
> +After=wireplumber.service
> +Wants=wireplumber.service

As per the systemd manual [0], with "Wants=" the service will still run
if wireplumber fails. From the script below I see that is not the
intension. "Requires=" would be the correct way. 

> +
> +[Service]
> +Type=oneshot
> +ExecStart=/usr/bin/set-audio-defaults.sh
> +StandardOutput=append:/var/log/set-audio-defaults-output.log
> +StandardError=append:/var/log/set-audio-defaults-error.log
> +RemainAfterExit=yes
> +
> +[Install]
> +WantedBy=multi-user.target
> diff --git 
> a/meta-arago-distro/recipes-multimedia/wireplumber/wireplumber/set-audio-defaults.sh
>  
> b/meta-arago-distro/recipes-multimedia/wireplumber/wireplumber/set-audio-defaults.sh
> new file mode 100755
> index 00000000..cd193d02
> --- /dev/null
> +++ 
> b/meta-arago-distro/recipes-multimedia/wireplumber/wireplumber/set-audio-defaults.sh
> @@ -0,0 +1,30 @@
> +#!/bin/bash
> +
> +# Wait for WirePlumber to be ready
> +for i in {1..30}; do
> +    wpctl status &>/dev/null && break
> +    sleep 1
> +done
> +
> +# Additional delay for nodes to appear
> +sleep 2
> +
> +# Find McASP sink ID
> +SINK_ID=$(pw-cli info alsa_multidac_8ch 2>/dev/null | head -n 1 | awk 
> '{print $2}')
> +if [[ -n "$SINK_ID" ]]; then
> +    wpctl set-default "$SINK_ID"
> +    echo "Set default sink to ID: $SINK_ID (alsa_multidac_8ch)"
> +else
> +    echo "Could not find alsa_multidac_8ch sink"
> +fi
> +
> +# Find PCM source ID
> +SOURCE_ID=$(pw-cli info alsa_multidac_4ch_capture 2>/dev/null | head -n 1 | 
> awk '{print $2}')
> +if [[ -n "$SOURCE_ID" ]]; then
> +    wpctl set-default "$SOURCE_ID"
> +    echo "Set default source to ID: $SOURCE_ID (alsa_multidac_4ch_capture)"
> +else
> +    echo "Could not find alsa_multidac_4ch_capture"
> +fi
> +
> +echo "Done"
> diff --git 
> a/meta-arago-distro/recipes-multimedia/wireplumber/wireplumber_0.5.1.bbappend 
> b/meta-arago-distro/recipes-multimedia/wireplumber/wireplumber_0.5.1.bbappend
> new file mode 100644
> index 00000000..f6e5ff91
> --- /dev/null
> +++ 
> b/meta-arago-distro/recipes-multimedia/wireplumber/wireplumber_0.5.1.bbappend
> @@ -0,0 +1,25 @@
> +SRC_URI += " \
> +    file://set-audio-defaults.sh \
> +    file://set-audio-defaults.service \
> +"
> +
> +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"

FILESEXTRAPATHS should be before SRC_URI. 

> +
> +do_install:append() {
> +    # Install the script
> +    install -d ${D}${bindir}
> +    install -m 0755 ${WORKDIR}/set-audio-defaults.sh ${D}${bindir}/
> +
> +    # Install the systemd service
> +    install -d ${D}${systemd_system_unitdir}
> +    install -m 0644 ${WORKDIR}/set-audio-defaults.service 
> ${D}${systemd_system_unitdir}/
> +}
> +
> +inherit systemd

As per yocto docs [1], systemd bbclass will take care of installing the service 
files 
and the lines installing the service files can be dropped. But for this
to work inherit systemdm, should be above do_install(). 

> +
> +RDEPENDS:${PN} += "bash"
> +SYSTEMD_SERVICE:${PN} = "set-audio-defaults.service"
> +
> +FILES:${PN} += " \
> +    ${bindir} \
> +"
> -- 
> 2.34.1
> 

[0]: 
https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html?__goaway_challenge=meta-refresh&__goaway_id=43a15b62025865117ca287aaee83857e
[1]: https://docs.yoctoproject.org/5.0.15/ref-manual/classes.html#systemd

Regards, 
- Yogesh


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#17026): 
https://lists.yoctoproject.org/g/meta-arago/message/17026
Mute This Topic: https://lists.yoctoproject.org/mt/117414046/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-arago/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to