eufon

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit e4f7e911b89b838b0665165bcfb4da4301f55d5b
parent 8c34f9429e2eb358980b46377eab13ad961d14be
Author: Daniel Barlow <dan@telent.net>
Date:   Tue,  5 Apr 2022 21:34:14 +0000

metric: don't hardcode battery name

bl: red background if battery is low

Diffstat:
Mblinkenlicht/bl.fnl | 5+++--
Mblinkenlicht/licht.css | 4++++
Mblinkenlicht/metric.fnl | 4++--
3 files changed, 9 insertions(+), 4 deletions(-)

diff --git 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 @@ -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 @@ -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")]