eufon/blinkenlicht/bl.fnl

55 lines
1.7 KiB
Plaintext
Raw Normal View History

(local {: bar : indicator : stylesheet : run} (require :blinkenlicht))
(local {: view} (require :fennel))
(local metric (require :metric))
2022-03-23 22:58:00 +00:00
(stylesheet "licht.css")
2022-03-24 12:13:17 +00:00
2022-03-24 22:45:53 +00:00
(fn battery-icon-codepoint [status percent]
(if ; (= status "Charging") 0xf376 ; glyph not present in font-awesome free
(> percent 90) 0xf240 ;full
(> percent 60) 0xf241 ;3/4
(> percent 40) 0xf242 ;1/2
(> percent 15) 0xf243 ;1/4
(>= percent 0) 0xf244 ;empty
; 0xf377 ; glyph not present in font-awesome free
))
2022-03-23 22:58:00 +00:00
(fn spawn []
true)
(bar
{
:anchor [:top :right]
:orientation :horizontal
:classes ["hey"]
2022-03-23 22:58:00 +00:00
:indicators
[
(indicator {
:interval 200
:icon #(if (> (metric.loadavg) 2) "face-sad" "face-smile")
2022-03-23 22:58:00 +00:00
})
;; (let [f (io.open "/tmp/statuspipe" "r")]
;; (indicator {
;; :poll [f]
;; :text #((f:read):sub 1 10)
;; }))
(indicator {
2022-03-24 12:13:17 +00:00
:interval (* 10 1000)
:classes ["yellow"]
2022-03-24 12:13:17 +00:00
:text #(let [{:power-supply-energy-full full
2022-03-24 22:45:53 +00:00
:power-supply-energy-now now
:power-supply-status status} (metric.battery)
2022-03-24 22:45:53 +00:00
percent (math.floor (* 100 (/ (tonumber now) (tonumber full))))
icon-code (battery-icon-codepoint status percent)]
(string.format "%s %d%%" (utf8.char icon-code) percent))
2022-03-23 22:58:00 +00:00
})
(indicator {
:interval 1000
2022-03-24 22:46:14 +00:00
:text #(os.date "%H:%M")
2022-03-23 22:58:00 +00:00
})
]})
(run)