From 8abb028c8260d8a86b9152223da7bfc7d3792ba9 Mon Sep 17 00:00:00 2001 From: NeilClack Date: Fri, 7 Aug 2026 23:58:25 -0500 Subject: [PATCH] fix wpctl volume pinning --- configuration.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/configuration.nix b/configuration.nix index fa25772..957a7f2 100644 --- a/configuration.nix +++ b/configuration.nix @@ -173,11 +173,13 @@ in Type = "oneshot"; }; 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="" for i in {1..30}; do 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 break fi @@ -193,6 +195,10 @@ in # 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-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 ''; };