From 58096c09ed2a75631688c57c543f0b16ece2c9b6 Mon Sep 17 00:00:00 2001 From: Bernardo Magri Date: Sun, 14 Jun 2026 12:51:01 +0100 Subject: [PATCH] fix(hyprland): show the mic level in the mute OSD The wpctl-based mic toggle lost the volume bar the native swayosd input OSD used to draw -- it only showed an icon + text. swayosd 0.3.x exposes --custom-progress (0.0-1.0), so read the level back from wpctl after the toggle and render icon + bar (muted/active glyph via --custom-icon), matching the output-volume OSD. Parsing is pure bash builtins so the script needs no PATH beyond the two pinned tools. Co-Authored-By: Claude Opus 4.8 --- modules/home/hyprland.nix | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) 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.