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 <noreply@anthropic.com>
This commit is contained in:
@@ -8,22 +8,23 @@ let
|
|||||||
c = t.colors;
|
c = t.colors;
|
||||||
inherit (config.nomarchy.lib) rgb rgba;
|
inherit (config.nomarchy.lib) rgb rgba;
|
||||||
|
|
||||||
# swayosd 0.2.1's `--input-volume mute-toggle` draws the OSD but never
|
# swayosd's `--input-volume mute-toggle` draws the OSD but never flips the
|
||||||
# flips the source mute (verified on hardware: wpctl toggles the state,
|
# source mute (verified on hardware: wpctl toggles the state, swayosd's
|
||||||
# swayosd's input-mute path is a no-op — unlike its working output-mute
|
# input-mute path is a no-op — unlike its working output-mute path). Do the
|
||||||
# path). Do the real toggle with wpctl, then show an OSD reflecting the
|
# real toggle with wpctl, then re-render the same icon + volume-bar OSD the
|
||||||
# resulting state via swayosd's --custom-icon/--custom-message.
|
# 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" ''
|
micMute = pkgs.writeShellScript "nomarchy-mic-mute" ''
|
||||||
${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_SOURCE@ toggle
|
${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_SOURCE@ toggle
|
||||||
if ${pkgs.wireplumber}/bin/wpctl get-volume @DEFAULT_SOURCE@ | grep -q MUTED; then
|
out=$(${pkgs.wireplumber}/bin/wpctl get-volume @DEFAULT_SOURCE@)
|
||||||
${pkgs.swayosd}/bin/swayosd-client \
|
set -- $out # "Volume: 0.85 [MUTED]" -> $2 is the level
|
||||||
--custom-icon microphone-sensitivity-muted-symbolic \
|
case "$out" in
|
||||||
--custom-message "Microphone muted"
|
*MUTED*) icon=microphone-sensitivity-muted-symbolic ;;
|
||||||
else
|
*) icon=microphone-sensitivity-high-symbolic ;;
|
||||||
${pkgs.swayosd}/bin/swayosd-client \
|
esac
|
||||||
--custom-icon microphone-sensitivity-high-symbolic \
|
${pkgs.swayosd}/bin/swayosd-client --custom-icon "$icon" --custom-progress "$2"
|
||||||
--custom-message "Microphone unmuted"
|
|
||||||
fi
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# SUPER+1..9 / SUPER+SHIFT+1..9 workspace binds, generated.
|
# SUPER+1..9 / SUPER+SHIFT+1..9 workspace binds, generated.
|
||||||
|
|||||||
Reference in New Issue
Block a user