From bdbb944ad5586ecbcfdee9be616d0020d523aaf1 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Thu, 11 May 2023 14:07:39 -0500 Subject: [PATCH] Listeners for volume and mic mute bar --- .../arch/provision.d/optional/ui-packages.bash | 2 +- os/linux/eww/eww.yuck | 18 +++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/os/linux/arch/provision.d/optional/ui-packages.bash b/os/linux/arch/provision.d/optional/ui-packages.bash index 51847e5..1c7b6ae 100755 --- a/os/linux/arch/provision.d/optional/ui-packages.bash +++ b/os/linux/arch/provision.d/optional/ui-packages.bash @@ -30,7 +30,7 @@ paru -Sy --needed \ passff-host `# Pass integration in Firefox` \ kitty-git `# Terminal Emulator` \ wezterm `# Terminal Emulator` \ - pavucontrol pamixer `# Pulseaudio Controls` \ + pavucontrol pamixer pactl `# Pulseaudio Controls` \ playerctl `# Media Keys Controls` \ feh `# Image Viewer and Wallpaper Manager` \ hyprland hyprpaper `# Wayland Compositor` \ diff --git a/os/linux/eww/eww.yuck b/os/linux/eww/eww.yuck index 1267406..685cc13 100644 --- a/os/linux/eww/eww.yuck +++ b/os/linux/eww/eww.yuck @@ -22,7 +22,7 @@ time ; TODO: idle inhibitor? ; TODO: get these to align properly? - (box :class "mic" (box :class {micMuted == "false" ? "muted" : "live"} {micMuted == "false" ? " " : " "})) + (box :class "mic" (box :class {micMuted == "false" ? "live" : "muted"} {micMuted == "false" ? " " : " "})) {"󰕾 " + volume} {" " + cpu} {" " + ram} @@ -40,20 +40,16 @@ (deflisten music :initial "" "playerctl --follow metadata --format '{{ title }} by {{ artist }}' || true") -; convert these to `deflisten`s as well because polling is very silly -(defpoll volume :interval "1s" - "pamixer --get-volume") +(deflisten volume :initial "0" + "pamixer --get-volume; pactl subscribe | grep sink --line-buffered | while read i; do pamixer --get-volume; done") -(defpoll micVolume :interval "10s" - "pamixer --default-source --get-volume") +(deflisten micMuted :initial "false" + "pamixer --default-source --get-mute; pactl subscribe | grep source --line-buffered | while read i; do pamixer --default-source --get-mute; done") -(defpoll micMuted :interval "1s" - "pamixer --default-source --get-mute") - -(defpoll cpu :interval "1s" +(defpoll cpu :interval "5s" "mpstat -o JSON | jq -r '(100 - .sysstat.hosts[0].statistics[0][\"cpu-load\"][0].idle | round | tostring)+\"%\"'") -(defpoll ram :interval "1s" +(defpoll ram :interval "5s" "free | grep Mem | awk '{printf \"%.0f%\", $3/$2 * 100.0}'") (defpoll time :interval "1s"