diff --git a/blinkenlicht/bl.fnl b/blinkenlicht/bl.fnl index 5f7d4d9..d0bd88c 100644 --- a/blinkenlicht/bl.fnl +++ b/blinkenlicht/bl.fnl @@ -86,12 +86,13 @@ :wait-for { :interval (* 1000 10) } :refresh #(let [{:power-supply-capacity percent - :power-supply-status status} (metric.battery) + :power-supply-status status} + (metric.battery "axp20x-battery") icon-code (battery-icon-codepoint status (tonumber percent))] {:text (string.format "%s %d%%" (utf8.char icon-code) percent) - :classes ["yellow"] + :classes ["battery" (if (< (tonumber percent) 20) "low" "ok")] }) }) (indicator { diff --git a/blinkenlicht/licht.css b/blinkenlicht/licht.css index fb47e63..9aac217 100644 --- a/blinkenlicht/licht.css +++ b/blinkenlicht/licht.css @@ -7,6 +7,10 @@ margin: 5px 0px 5px 12px; } +.battery.low { + background-color: #e00; +} + .bar { background-color: #200; } diff --git a/blinkenlicht/metric.fnl b/blinkenlicht/metric.fnl index 752b93a..d963a23 100644 --- a/blinkenlicht/metric.fnl +++ b/blinkenlicht/metric.fnl @@ -6,8 +6,8 @@ (one five fifteen) (line:match "([%d.]+) +([%d.]+) +([%d.]+)")] (values (tonumber one) (tonumber five) (tonumber fifteen))))) -(fn battery [path] - (let [name (.. (or path "/sys/class/power_supply/BAT0") "/uevent")] +(fn battery [name] + (let [name (.. "/sys/class/power_supply/" name "/uevent")] (with-open [f (io.open name :r)] (let [fields {}] (each [line #(f:read "*l")]