From d5b416a5b835658ab5d51695c2f289afa67598d5 Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Sun, 24 Sep 2023 16:48:18 +0200 Subject: [PATCH] pinwheel: Toggle mute LED when (un)muting --- hosts/pinwheel/modules/sound/default.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hosts/pinwheel/modules/sound/default.nix b/hosts/pinwheel/modules/sound/default.nix index 857e1a9..bb759f8 100644 --- a/hosts/pinwheel/modules/sound/default.nix +++ b/hosts/pinwheel/modules/sound/default.nix @@ -1,4 +1,11 @@ { pkgs, ... }: +let + toggle-mute = pkgs.writeShellScript "foo" '' + ${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle + MUTED=$(${pkgs.wireplumber}/bin/wpctl get-volume @DEFAULT_AUDIO_SINK@ | grep MUTED | wc -l) + echo $MUTED > /sys/class/leds/platform::mute/brightness + ''; +in { users.users.alex.extraGroups = [ "audio" ]; @@ -22,7 +29,7 @@ bind = [ ", XF86AudioRaiseVolume, exec, ${pkgs.wireplumber}/bin/wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 2%+" ", XF86AudioLowerVolume, exec, ${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ 2%-" - ", XF86AudioMute, exec, ${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle" + ", XF86AudioMute, exec, ${toggle-mute}" ", XF86AudioMicMute, exec, ${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle" ]; };