fix wpctl volume pinning

This commit is contained in:
NeilClack
2026-08-07 23:58:25 -05:00
parent 1e0380a8c4
commit 8abb028c82
+8 -2
View File
@@ -173,11 +173,13 @@ in
Type = "oneshot"; Type = "oneshot";
}; };
script = '' script = ''
# Wait until WirePlumber exposes at least one sink # Wait until WirePlumber exposes at least one sink.
# `wpctl list` output is tab-separated: ID, name, media/object type,
# then `*` if the node is the current default. `cut -f1` grabs the ID.
sinks="" sinks=""
for i in {1..30}; do for i in {1..30}; do
sinks=$(${pkgs.wireplumber}/bin/wpctl list audio sinks 2>/dev/null \ sinks=$(${pkgs.wireplumber}/bin/wpctl list audio sinks 2>/dev/null \
| ${pkgs.gnused}/bin/sed -nE 's/^.*[^0-9]([0-9]+)\. .*$/\1/p') | ${pkgs.coreutils}/bin/cut -f1)
if [ -n "$sinks" ]; then if [ -n "$sinks" ]; then
break break
fi fi
@@ -193,6 +195,10 @@ in
# Fallback in case the sink list came up empty # Fallback in case the sink list came up empty
${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ 1.0 2>/dev/null || true ${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ 1.0 2>/dev/null || true
${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SINK@ 0 2>/dev/null || true ${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SINK@ 0 2>/dev/null || true
# Persist 100% as WirePlumber's default for any brand-new sink so it
# comes up at full volume even before this service runs on next boot.
${pkgs.wireplumber}/bin/wpctl settings device.routes.default-sink-volume 1.0 --save 2>/dev/null || true
''; '';
}; };