metric: don't hardcode battery name
bl: red background if battery is low
This commit is contained in:
parent
8c34f9429e
commit
e4f7e911b8
@ -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 {
|
||||
|
@ -7,6 +7,10 @@
|
||||
margin: 5px 0px 5px 12px;
|
||||
}
|
||||
|
||||
.battery.low {
|
||||
background-color: #e00;
|
||||
}
|
||||
|
||||
.bar {
|
||||
background-color: #200;
|
||||
}
|
||||
|
@ -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")]
|
||||
|
Loading…
Reference in New Issue
Block a user