feat(waybar): fix wireplumber
This commit is contained in:
parent
2c4ff5cb8c
commit
6764b5c28e
1 changed files with 44 additions and 43 deletions
|
|
@ -55,6 +55,34 @@ let
|
|||
foreground = "${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
|
||||
{
|
||||
home.sessionVariables = lib.mkMerge [
|
||||
|
|
@ -106,8 +134,8 @@ in
|
|||
"tray"
|
||||
"custom/keyboard"
|
||||
"privacy"
|
||||
"wireplumber#source"
|
||||
"wireplumber"
|
||||
"custom/source"
|
||||
"custom/sink"
|
||||
"network"
|
||||
"battery"
|
||||
"clock"
|
||||
|
|
@ -149,54 +177,26 @@ in
|
|||
rewrite = { };
|
||||
};
|
||||
|
||||
wireplumber = {
|
||||
format = "{icon}";
|
||||
format-muted = "";
|
||||
format-icons = [
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
];
|
||||
node-type = "Audio/Sink";
|
||||
max-volume = 100;
|
||||
scroll-step = 5;
|
||||
"custom/sink" = {
|
||||
exec = "${wpSink}";
|
||||
return-type = "json";
|
||||
interval = 1;
|
||||
on-click = "ctl audio sink";
|
||||
on-click-right = "ctl audio sink";
|
||||
on-click-middle = "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle";
|
||||
tooltip = true;
|
||||
tooltip-format = "Volume: {volume}%";
|
||||
on-scroll-up = "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+ --limit 1.0";
|
||||
on-scroll-down = "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-";
|
||||
};
|
||||
|
||||
"wireplumber#source" = {
|
||||
format = "{icon}";
|
||||
format-muted = "";
|
||||
format-icons = [
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
""
|
||||
];
|
||||
node-type = "Audio/Source";
|
||||
max-volume = 100;
|
||||
scroll-step = 5;
|
||||
"custom/source" = {
|
||||
exec = "${wpSource}";
|
||||
return-type = "json";
|
||||
interval = 1;
|
||||
on-click = "ctl audio source";
|
||||
on-click-right = "ctl audio source";
|
||||
on-click-middle = "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle";
|
||||
tooltip = true;
|
||||
tooltip-format = "Volume: {volume}%";
|
||||
on-scroll-up = "wpctl set-volume @DEFAULT_AUDIO_SOURCE@ 5%+ --limit 1.0";
|
||||
on-scroll-down = "wpctl set-volume @DEFAULT_AUDIO_SOURCE@ 5%-";
|
||||
};
|
||||
|
||||
network = {
|
||||
|
|
@ -285,7 +285,8 @@ in
|
|||
#custom-keyboard,
|
||||
#privacy,
|
||||
#tray,
|
||||
#wireplumber,
|
||||
#custom-sink,
|
||||
#custom-source,
|
||||
#network,
|
||||
#battery,
|
||||
#clock,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue