feat(waybar): fix wireplumber

This commit is contained in:
Barrett Ruth 2026-03-06 16:44:53 -05:00
parent 2c4ff5cb8c
commit 6764b5c28e
Signed by: barrett
GPG key ID: A6C96C9349D2FC81

View file

@ -55,6 +55,34 @@ let
foreground = "${palette.red}" foreground = "${palette.red}"
frame_color = "${palette.red}" frame_color = "${palette.red}"
''; '';
wpSink = pkgs.writeShellScript "waybar-sink" ''
vol=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ 2>/dev/null)
pct=$(printf '%s' "$vol" | awk '{printf "%d", $2 * 100}')
name=$(wpctl inspect @DEFAULT_AUDIO_SINK@ 2>/dev/null | awk -F'"' '/node\.description/{print $2; exit}')
if printf '%s' "$vol" | grep -q MUTED; then
icon="󰖁"
elif [ "$pct" -le 33 ]; then
icon="󰕿"
elif [ "$pct" -le 66 ]; then
icon="󰖀"
else
icon="󰕾"
fi
printf '{"text":"%s","tooltip":"Sink: %s\\nVolume: %d%%"}\n' "$icon" "$name" "$pct"
'';
wpSource = pkgs.writeShellScript "waybar-source" ''
vol=$(wpctl get-volume @DEFAULT_AUDIO_SOURCE@ 2>/dev/null)
pct=$(printf '%s' "$vol" | awk '{printf "%d", $2 * 100}')
name=$(wpctl inspect @DEFAULT_AUDIO_SOURCE@ 2>/dev/null | awk -F'"' '/node\.description/{print $2; exit}')
if printf '%s' "$vol" | grep -q MUTED; then
icon="󰍭"
else
icon="󰍬"
fi
printf '{"text":"%s","tooltip":"Source: %s\\nVolume: %d%%"}\n' "$icon" "$name" "$pct"
'';
in in
{ {
home.sessionVariables = lib.mkMerge [ home.sessionVariables = lib.mkMerge [
@ -106,8 +134,8 @@ in
"tray" "tray"
"custom/keyboard" "custom/keyboard"
"privacy" "privacy"
"wireplumber#source" "custom/source"
"wireplumber" "custom/sink"
"network" "network"
"battery" "battery"
"clock" "clock"
@ -149,54 +177,26 @@ in
rewrite = { }; rewrite = { };
}; };
wireplumber = { "custom/sink" = {
format = "{icon}"; exec = "${wpSink}";
format-muted = "󰖁"; return-type = "json";
format-icons = [ interval = 1;
"󰖁"
"󰕿"
"󰕿"
"󰕿"
"󰖀"
"󰖀"
"󰖀"
"󰕾"
"󰕾"
"󰕾"
];
node-type = "Audio/Sink";
max-volume = 100;
scroll-step = 5;
on-click = "ctl audio sink"; on-click = "ctl audio sink";
on-click-right = "ctl audio sink"; on-click-right = "ctl audio sink";
on-click-middle = "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; on-click-middle = "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle";
tooltip = true; on-scroll-up = "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+ --limit 1.0";
tooltip-format = "Volume: {volume}%"; on-scroll-down = "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-";
}; };
"wireplumber#source" = { "custom/source" = {
format = "{icon}"; exec = "${wpSource}";
format-muted = "󰍭"; return-type = "json";
format-icons = [ interval = 1;
"󰍭"
"󰍬"
"󰍬"
"󰍬"
"󰍬"
"󰍬"
"󰍬"
"󰍬"
"󰍬"
"󰍬"
];
node-type = "Audio/Source";
max-volume = 100;
scroll-step = 5;
on-click = "ctl audio source"; on-click = "ctl audio source";
on-click-right = "ctl audio source"; on-click-right = "ctl audio source";
on-click-middle = "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"; on-click-middle = "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle";
tooltip = true; on-scroll-up = "wpctl set-volume @DEFAULT_AUDIO_SOURCE@ 5%+ --limit 1.0";
tooltip-format = "Volume: {volume}%"; on-scroll-down = "wpctl set-volume @DEFAULT_AUDIO_SOURCE@ 5%-";
}; };
network = { network = {
@ -285,7 +285,8 @@ in
#custom-keyboard, #custom-keyboard,
#privacy, #privacy,
#tray, #tray,
#wireplumber, #custom-sink,
#custom-source,
#network, #network,
#battery, #battery,
#clock, #clock,