2022-03-25 10:47:32 +00:00
|
|
|
(local {: bar : indicator : stylesheet : run} (require :blinkenlicht))
|
2022-04-05 21:14:17 +00:00
|
|
|
|
2022-03-25 11:21:21 +00:00
|
|
|
(local {: view} (require :fennel))
|
2022-03-25 10:47:32 +00:00
|
|
|
|
2022-03-27 17:42:44 +00:00
|
|
|
(local iostream (require :iostream))
|
2022-03-25 11:21:21 +00:00
|
|
|
(local metric (require :metric))
|
2022-04-03 17:09:02 +00:00
|
|
|
(local uplink (require :uplink))
|
2022-04-05 20:57:44 +00:00
|
|
|
(local modem (require :modem))
|
2022-03-23 22:58:00 +00:00
|
|
|
|
2022-03-25 11:21:21 +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]
|
2022-04-01 15:21:03 +00:00
|
|
|
(if (= status "Charging") 0xf0e7
|
2022-03-24 22:45:53 +00:00
|
|
|
(> 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
|
|
|
|
{
|
2022-04-05 21:09:52 +00:00
|
|
|
;; bar must be full width to set up an "exclusive zone" (moves
|
|
|
|
;; other windows out of the way), otherwise it will display on
|
|
|
|
;; to of whatever's on the screen already
|
|
|
|
:anchor [:top :right :left]
|
2022-03-23 22:58:00 +00:00
|
|
|
:orientation :horizontal
|
2022-04-05 21:09:52 +00:00
|
|
|
:gravity :end
|
2022-03-25 10:47:32 +00:00
|
|
|
:classes ["hey"]
|
2022-03-23 22:58:00 +00:00
|
|
|
:indicators
|
|
|
|
[
|
2022-03-27 15:24:00 +00:00
|
|
|
(let []
|
|
|
|
(var previous 0)
|
|
|
|
;; on my laptop, adding this indicator has made the task
|
|
|
|
;; go from ~ 1% cpu to around 3%, which is not ideal
|
|
|
|
(indicator {
|
|
|
|
:wait-for { :interval (* 1 500) }
|
|
|
|
:refresh
|
|
|
|
#(let [current (. (metric.cpustat) :iowait)
|
2022-04-01 15:19:16 +00:00
|
|
|
delta (- current previous)
|
|
|
|
v (if (> delta 4) "" " ")]
|
2022-03-27 15:24:00 +00:00
|
|
|
(set previous current)
|
|
|
|
{:text v})
|
|
|
|
}))
|
|
|
|
|
2022-04-05 20:57:44 +00:00
|
|
|
(let [modem (modem.new)]
|
|
|
|
(indicator {
|
|
|
|
:wait-for {
|
|
|
|
:interval (* 4 1000)
|
|
|
|
}
|
|
|
|
:refresh
|
|
|
|
#(let [{:m3gpp-operator-name operator
|
|
|
|
:signal-quality quality} (modem:value)]
|
|
|
|
{:text (.. operator
|
|
|
|
;" " (. quality 1) "dBm"
|
|
|
|
)
|
|
|
|
})
|
|
|
|
}))
|
|
|
|
|
2022-04-03 17:09:02 +00:00
|
|
|
(let [uplink (uplink.new)
|
|
|
|
input (iostream.from-descriptor uplink.fd)]
|
|
|
|
(indicator {
|
|
|
|
:wait-for {
|
|
|
|
:input [input]
|
|
|
|
}
|
|
|
|
:refresh
|
|
|
|
#(let [status (uplink:status)]
|
|
|
|
(if status
|
|
|
|
{:text (.. (or status.ssid status.name "?")
|
|
|
|
" "
|
|
|
|
(if status.quality
|
2022-04-05 21:14:17 +00:00
|
|
|
;; this is in dBm, allegedly.
|
|
|
|
;; typical values
|
|
|
|
;; -20 (good) -> -100 (awful)
|
2022-04-03 17:09:02 +00:00
|
|
|
(tostring (+ status.quality 100))
|
|
|
|
""))}
|
|
|
|
{:text "no internet"}
|
|
|
|
))
|
|
|
|
}))
|
|
|
|
|
2022-03-23 22:58:00 +00:00
|
|
|
(indicator {
|
2022-03-26 18:08:25 +00:00
|
|
|
:wait-for { :interval (* 1000 10) }
|
|
|
|
:refresh
|
2022-04-05 21:14:17 +00:00
|
|
|
#(let [{:power-supply-capacity percent
|
2022-03-26 18:08:25 +00:00
|
|
|
:power-supply-status status} (metric.battery)
|
2022-04-05 21:14:17 +00:00
|
|
|
icon-code (battery-icon-codepoint
|
|
|
|
status (tonumber percent))]
|
2022-03-26 18:08:25 +00:00
|
|
|
{:text
|
|
|
|
(string.format "%s %d%%" (utf8.char icon-code) percent)
|
|
|
|
:classes ["yellow"]
|
|
|
|
})
|
2022-03-23 22:58:00 +00:00
|
|
|
})
|
|
|
|
(indicator {
|
2022-03-26 18:08:25 +00:00
|
|
|
:wait-for { :interval 4000 }
|
2022-04-05 21:14:17 +00:00
|
|
|
:refresh #{:text (os.date "%H:%M")}
|
2022-03-23 22:58:00 +00:00
|
|
|
})
|
2022-04-05 21:14:17 +00:00
|
|
|
|
2022-03-23 22:58:00 +00:00
|
|
|
]})
|
|
|
|
|
|
|
|
(run)
|