diff --git a/modules/home/hyprland.nix b/modules/home/hyprland.nix index e40c8e8..13260da 100644 --- a/modules/home/hyprland.nix +++ b/modules/home/hyprland.nix @@ -8,22 +8,23 @@ let c = t.colors; inherit (config.nomarchy.lib) rgb rgba; - # swayosd 0.2.1's `--input-volume mute-toggle` draws the OSD but never - # flips the source mute (verified on hardware: wpctl toggles the state, - # swayosd's input-mute path is a no-op — unlike its working output-mute - # path). Do the real toggle with wpctl, then show an OSD reflecting the - # resulting state via swayosd's --custom-icon/--custom-message. + # swayosd's `--input-volume mute-toggle` draws the OSD but never flips the + # source mute (verified on hardware: wpctl toggles the state, swayosd's + # input-mute path is a no-op — unlike its working output-mute path). Do the + # real toggle with wpctl, then re-render the same icon + volume-bar OSD the + # native input path would, reading the resulting state back from wpctl: + # --custom-progress is the mic level (0.0-1.0), --custom-icon the + # muted/active glyph. Pure bash builtins for parsing so the script needs no + # PATH beyond the two pinned tools. micMute = pkgs.writeShellScript "nomarchy-mic-mute" '' ${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_SOURCE@ toggle - if ${pkgs.wireplumber}/bin/wpctl get-volume @DEFAULT_SOURCE@ | grep -q MUTED; then - ${pkgs.swayosd}/bin/swayosd-client \ - --custom-icon microphone-sensitivity-muted-symbolic \ - --custom-message "Microphone muted" - else - ${pkgs.swayosd}/bin/swayosd-client \ - --custom-icon microphone-sensitivity-high-symbolic \ - --custom-message "Microphone unmuted" - fi + out=$(${pkgs.wireplumber}/bin/wpctl get-volume @DEFAULT_SOURCE@) + set -- $out # "Volume: 0.85 [MUTED]" -> $2 is the level + case "$out" in + *MUTED*) icon=microphone-sensitivity-muted-symbolic ;; + *) icon=microphone-sensitivity-high-symbolic ;; + esac + ${pkgs.swayosd}/bin/swayosd-client --custom-icon "$icon" --custom-progress "$2" ''; # SUPER+1..9 / SUPER+SHIFT+1..9 workspace binds, generated.