add icons for battery status

phoen
Daniel Barlow 2022-03-24 22:45:53 +00:00
parent 48ffaa7695
commit 8abdffdbec
1 changed files with 16 additions and 9 deletions

View File

@ -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