46 lines
1.2 KiB
Fennel
46 lines
1.2 KiB
Fennel
;;; 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
|