Battery time

This commit is contained in:
Daniel Flanagan 2024-03-27 12:39:22 -05:00
parent f514f5addc
commit 92cd2922b2

View file

@ -42,16 +42,16 @@
; TODO: get these to align properly? icons seem lower than they should be?
(box :class "mic" (
box :class {micMuted == "false" ? "live" : "muted"} {micMuted == "false" ? " " : " "}
) {micVolume + "%"}
) {"${micVolume}%"}
)
(box :class "vol" (
box :class {muted == "false" ? "live" : "muted"} {muted == "false" ? "󰕾 " : "󰖁 "}
) {volume + "%"}
) {"${volume}%"}
)
{" " + round(EWW_CPU["avg"], 0) + "%"}
{" " + round(EWW_RAM["used_mem_perc"], 0) + "%"}
{showBrightness == "true" ? "" : " " + brightness + "%"}
{showBattery == "true" ? "" : "󱊣 " + EWW_BATTERY["BAT1"]["capacity"] + "%"}
{" ${round(EWW_CPU["avg"], 0)}%"}
{" ${round(EWW_RAM["used_mem_perc"], 0)}%"}
{showBrightness == "false" ? "" : (" ${brightness}%")}
{showBattery == "false" ? "" : ("󱊣 ${EWW_BATTERY["BAT1"]["capacity"]}% (${batteryTime})")}
))
(defwidget music []
@ -76,6 +76,12 @@
(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")
(deflisten batteryTime :initial "unknown"
"upower -d | rg '\\s*time to empty:\\s*(\\d.*)\$' -r '\$1'")
; (deflisten batteryTime :initial "unknown"
; "upower -d | rg '\s*time to empty:\s*(\d.*)\$' -r '\$1'; upower --monitor-detail | rg '\s*time to empty:\s*(\d.*)\$' -r '\$1'")
(defpoll time :interval "1s"
"date '+%a %b %d %H:%M:%S'")
@ -85,10 +91,7 @@
(defpoll showBattery :interval "24h"
; if we have at least one battery in /sys/class/power_supply, we should try and show battery levels
"if [ \"$(find /sys/class/power_supply* -mindepth 1 -maxdepth 1 | grep '^BAT' | head -n 1 | wc -l)\" == \"1\" ]; then echo true; else echo false; fi")
"if find /sys/class/power_supply* -mindepth 1 -maxdepth 1 | rg '\/sys\/class\/power_supply\/BAT'; then echo true; else echo false; fi")
(defpoll brightness :interval "10s"
"echo $(((100 * $(brightnessctl get)) / $(brightnessctl max)))")
(defpoll monitor :interval "60s"
"echo $EWW_BAR_MON")