commit 3d5d1078c29f72bbd2205b8e35c6aae3b3f8066e
parent 8d8c65e5b394765f5e1fbead73ce6c6ef58c7c4d
Author: Daniel Barlow <dan@telent.net>
Date: Tue, 5 Apr 2022 21:14:17 +0000
tidy the example layout
Diffstat:
2 files changed, 11 insertions(+), 42 deletions(-)
diff --git a/blinkenlicht/bl.fnl b/blinkenlicht/bl.fnl
@@ -1,4 +1,5 @@
(local {: bar : indicator : stylesheet : run} (require :blinkenlicht))
+
(local {: view} (require :fennel))
(local iostream (require :iostream))
@@ -65,7 +66,6 @@
(indicator {
:wait-for {
:input [input]
- :interval (* 4 1000)
}
:refresh
#(let [status (uplink:status)]
@@ -73,60 +73,32 @@
{:text (.. (or status.ssid status.name "?")
" "
(if status.quality
+ ;; this is in dBm, allegedly.
+ ;; typical values
+ ;; -20 (good) -> -100 (awful)
(tostring (+ status.quality 100))
""))}
{:text "no internet"}
))
}))
- (let [f (iostream.open "/tmp/statuspipe" :r)]
- (indicator {
- ;; this is a guide to tell blinkenlicht when it might
- ;; be worth calling your `content` function. Your
- ;; function may be called at other times too
- :wait-for { :input [f] }
-
- ;; the `content` function should not block, so e.g
- ;; don't read from files unless you know there's data
- ;; available. it returns a hash
- ;; { :text "foo" } - render "foo" as a label
- ;; { :icon "face-sad" } - render icon from theme or pathname
- ;; { :classes ["foo" "bar"] - add CSS classes to widget
- :refresh
- #(let [l (f:read 1024)]
- (if l
- {:text l}))
- }))
-
- (indicator {
- :wait-for { :interval 2000 }
- :refresh
- #{:icon (if (> (metric.loadavg) 2) "face-sad" "face-smile")}
- })
-
(indicator {
:wait-for { :interval (* 1000 10) }
:refresh
- #(let [{:power-supply-energy-full full
- :power-supply-energy-now now
+ #(let [{:power-supply-capacity percent
:power-supply-status status} (metric.battery)
- percent (math.floor
- (* 100
- (/ (tonumber now) (tonumber full))))
- icon-code (battery-icon-codepoint status percent)]
+ icon-code (battery-icon-codepoint
+ status (tonumber percent))]
{:text
(string.format "%s %d%%" (utf8.char icon-code) percent)
:classes ["yellow"]
})
})
(indicator {
- :wait-for { :interval 1000 }
- :refresh #{:text (os.date "%H:%M:%S")}
- })
- (indicator {
:wait-for { :interval 4000 }
- :refresh #{:text (os.date "%H:%M:%S")}
+ :refresh #{:text (os.date "%H:%M")}
})
+
]})
(run)
diff --git a/blinkenlicht/licht.css b/blinkenlicht/licht.css
@@ -1,15 +1,12 @@
.indicator {
color: #eef;
- background-color: #000;
font-size: 11px;
}
.indicator * {
- margin: 5px 8px;
- padding: 5px 5px;
- background-color: #225;
+ margin: 5px 0px 5px 12px;
}
.bar {
- background-color: #000;
+ background-color: #200;
}