eufon

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

commit 8abdffdbecb6346caa0534476d07909a1925ae22
parent 48ffaa7695fc8cc9a393fe7baeb23db862d25066
Author: Daniel Barlow <dan@telent.net>
Date:   Thu, 24 Mar 2022 22:45:53 +0000

add icons for battery status

Diffstat:
Mblinkenlicht/bl.fnl | 25++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/blinkenlicht/bl.fnl b/blinkenlicht/bl.fnl @@ -16,6 +16,17 @@ (tset fields (: (name:gsub "_" "-") :lower) value))) fields)))) +(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 + )) + + (fn spawn [] true) @@ -37,15 +48,11 @@ (indicator { :interval (* 10 1000) :text #(let [{:power-supply-energy-full full - :power-supply-energy-now now} - (battery-status)] - (string.format "BAT %d%%" - (math.floor (* 100 (/ (tonumber now) (tonumber full)))))) - }) - (indicator { - :interval 5000 - :text #(.. (disk-free-percent "/") "%") - :on-click #(spawn "baobab") + :power-supply-energy-now now + :power-supply-status status} (battery-status) + percent (math.floor (* 100 (/ (tonumber now) (tonumber full)))) + icon-code (battery-icon-codepoint status percent)] + (string.format "%s %d%%" (utf8.char icon-code) percent)) }) (indicator { :interval 1000