diff --git a/module/sidebar.fnl b/module/sidebar.fnl index c9de34b..faabb9d 100644 --- a/module/sidebar.fnl +++ b/module/sidebar.fnl @@ -37,82 +37,8 @@ (local sb-systray (doto (wibox.widget.systray) (: :set_base_size 24))) -(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 28" icon)))) - -(fn bat-markup [] - (bat-icon)) - -(fn pulse-icon [] - (let [icon {:muted "\u{e133}" - :low "\u{e135}" - :med "\u{e132}" - :high "\u{e134}"} - muted (= _G.volume_now.muted "yes") - vol (tonumber _G.volume_now.left) - icon (if muted icon.muted - (> vol 35) icon.high - (> vol 5) icon.med - icon.low)] - (: _G.widget :set_markup (markup.font "Typicons 24" icon)))) - -(fn pulse-icon+text [] - (let [icon {:muted "\u{e133}" - :low "\u{e135}" - :med "\u{e132}" - :high "\u{e134}"} - muted (= _G.volume_now.muted "yes") - vol (tonumber _G.volume_now.left) - icon (if muted icon.muted - (> vol 35) icon.high - (> vol 5) icon.med - icon.low) - s (if muted "" - (.. "\n" (tostring vol) "%"))] - (: _G.widget :set_markup - (.. (markup.font "Typicons 24" icon) - s)))) - -(fn pulse-markup [] - (pulse-icon)) - -;; TODO Plug/unplug notifications -(local battery - (lain.widget.bat - {:battery "BAT1" - :ac "ACAD" - :notify "on" - :n_perc [10 20] - :settings bat-markup})) - -(local pulse (lain.widget.pulse - {:settings pulse-markup})) +(local battery (require :widget.bat)) +(local pulse (require :widget.pulse)) (fn draw-sidebar [s] (set s.sb (awful.wibar {:position beautiful.sidebar_position diff --git a/widget/bat.fnl b/widget/bat.fnl new file mode 100644 index 0000000..b4ec078 --- /dev/null +++ b/widget/bat.fnl @@ -0,0 +1,51 @@ +;;; 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 28" 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 diff --git a/widget/pulse.fnl b/widget/pulse.fnl new file mode 100644 index 0000000..ab258df --- /dev/null +++ b/widget/pulse.fnl @@ -0,0 +1,45 @@ +;;; widget/pulse.fnl --- Pulseaudio widget + +;;; Code: + +(local lain (require :lain)) +(local markup lain.util.markup) + +(fn pulse-icon [] + (let [icon {:muted "\u{e133}" + :low "\u{e135}" + :med "\u{e132}" + :high "\u{e134}"} + muted (= _G.volume_now.muted "yes") + vol (tonumber _G.volume_now.left) + icon (if muted icon.muted + (> vol 35) icon.high + (> vol 5) icon.med + icon.low)] + (: _G.widget :set_markup (markup.font "Typicons 24" icon)))) + +(fn pulse-icon+text [] + (let [icon {:muted "\u{e133}" + :low "\u{e135}" + :med "\u{e132}" + :high "\u{e134}"} + muted (= _G.volume_now.muted "yes") + vol (tonumber _G.volume_now.left) + icon (if muted icon.muted + (> vol 35) icon.high + (> vol 5) icon.med + icon.low) + s (if muted "" + (.. "\n" (tostring vol) "%"))] + (: _G.widget :set_markup + (.. (markup.font "Typicons 24" icon) + s)))) + +(fn pulse-markup [] + (pulse-icon)) + +(local pulse (lain.widget.pulse + {:settings pulse-markup})) + +pulse +;;; widget/pulse.fnl ends here