awesome/widget/bat.fnl

52 lines
1.2 KiB
Plaintext
Raw Permalink Normal View History

;;; widget/bat.fnl --- Battery widget
;;; Code:
(local std (require :lib.std))
(local lain (require :lain))
(local markup lain.util.markup)
(fn bat-hm []
(let [[h m] (std.s-split _G.bat_now.time ":")
baticon "\u{f241}"]
(: _G.widget :set_markup
(.. baticon "\n" h "\n" m))))
(fn bat-icon []
;; FA
;; (let [full "\u{f240}"
;; x75 "\u{f241}"
;; x50 "\u{f242}"
;; x25 "\u{f243}"
;; empty "\u{f244}"
(let [full "\u{e02b}"
x75 "\u{e02c}"
x50 "\u{e02d}"
x25 "\u{e02e}"
empty "\u{e136}"
charging "\u{e02a}"
status _G.bat_now.status
level _G.bat_now.perc
icon (if (= status "Full") full
(= status "Charging") charging
(> level 75) x75
(> level 50) x50
(> level 25) x25
empty)]
(: _G.widget :set_markup (markup.font "Typicons 24" icon))))
(fn bat-markup []
(bat-icon))
;; TODO Plug/unplug notifications
(local battery
(lain.widget.bat
{:battery "BAT1"
:ac "ACAD"
:notify "on"
:n_perc [10 20]
:settings bat-markup}))
battery
;;; widget/bat.fnl ends here