2019-01-15 11:20:10 +11:00
|
|
|
;;; module/sidebar.fnl --- Informational sidebar
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
(local awful (require :awful))
|
|
|
|
(local beautiful (require :beautiful))
|
2019-01-15 16:33:58 +11:00
|
|
|
(local lain (require :lain))
|
2019-01-15 11:20:10 +11:00
|
|
|
(local wibox (require :wibox))
|
|
|
|
|
2019-01-15 16:33:58 +11:00
|
|
|
(local std (require :lib.std))
|
|
|
|
|
2019-01-15 11:37:47 +11:00
|
|
|
(local tag-list (require :widget.tag-list))
|
|
|
|
(local task-list (require :widget.task-list))
|
2019-01-15 15:14:29 +11:00
|
|
|
(local textclock (require :widget.textclock))
|
2019-01-15 11:20:10 +11:00
|
|
|
|
2019-01-15 16:33:58 +11:00
|
|
|
(local markup lain.util.markup)
|
|
|
|
|
2019-01-15 11:20:10 +11:00
|
|
|
;;;
|
|
|
|
;; Functions
|
|
|
|
|
2019-01-15 15:14:29 +11:00
|
|
|
(fn border [t margin]
|
|
|
|
(let [side (or margin 2)
|
|
|
|
end (+ side 1)]
|
|
|
|
{1 t
|
|
|
|
:bottom end
|
|
|
|
:left side
|
|
|
|
:right side
|
|
|
|
:top end
|
|
|
|
:widget wibox.container.margin} ))
|
|
|
|
|
2019-01-15 16:33:58 +11:00
|
|
|
(fn center [t]
|
|
|
|
{1 t
|
|
|
|
:align "center"
|
|
|
|
:widget wibox.container.place})
|
|
|
|
|
2019-01-15 15:14:29 +11:00
|
|
|
(local sb-clock (textclock "%H\n%M"))
|
|
|
|
(local sb-systray (doto (wibox.widget.systray)
|
|
|
|
(: :set_base_size 24)))
|
2019-01-15 16:33:58 +11:00
|
|
|
;; (fn bat-markup []
|
|
|
|
;; (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))))
|
|
|
|
|
|
|
|
;; TODO Plug/unplug notifications
|
|
|
|
(local battery
|
|
|
|
(lain.widget.bat
|
|
|
|
{:battery "BAT1"
|
|
|
|
:ac "ACAD"
|
|
|
|
:notify "on"
|
|
|
|
:n_perc [10 20]
|
|
|
|
:settings bat-icon}))
|
|
|
|
(local pulse (lain.widget.pulse))
|
2019-01-15 11:20:10 +11:00
|
|
|
|
2019-01-15 15:14:29 +11:00
|
|
|
(fn draw-sidebar [s]
|
2019-01-15 11:20:10 +11:00
|
|
|
(set s.sb (awful.wibar {:position beautiful.sidebar_position
|
|
|
|
:width beautiful.sidebar_width
|
|
|
|
:screen s}))
|
|
|
|
|
|
|
|
(: s.sb :setup
|
|
|
|
{:layout wibox.layout.align.vertical
|
2019-01-15 15:14:29 +11:00
|
|
|
1 {1 (border (tag-list s))
|
|
|
|
;; 2 (task-list s)
|
|
|
|
:layout wibox.layout.fixed.vertical}
|
2019-01-15 16:33:58 +11:00
|
|
|
2 nil
|
|
|
|
3 {1 (center battery.widget)
|
|
|
|
2 pulse.widget
|
|
|
|
;; 2 sb-systray
|
|
|
|
3 {1 (border
|
|
|
|
{1 {1 (center sb-clock)
|
2019-01-15 15:14:29 +11:00
|
|
|
:top 2
|
|
|
|
:bottom 2
|
|
|
|
:widget wibox.container.margin}
|
|
|
|
:widget wibox.container.background
|
|
|
|
:bg beautiful.sidebar_bg_info})
|
|
|
|
:layout wibox.layout.fixed.vertical}
|
|
|
|
:layout wibox.layout.fixed.vertical}}))
|
2019-01-15 11:20:10 +11:00
|
|
|
|
|
|
|
;;;
|
|
|
|
;; Configuration
|
|
|
|
|
2019-01-15 11:37:47 +11:00
|
|
|
(awful.screen.connect_for_each_screen
|
|
|
|
draw-sidebar)
|
2019-01-15 11:20:10 +11:00
|
|
|
|
|
|
|
{}
|
|
|
|
;;; module/sidebar.fnl ends here
|