awesome/module/sidebar.fnl

114 lines
3.0 KiB
Plaintext
Raw Normal View History

2019-01-15 11:20:10 +11:00
;;; module/sidebar.fnl --- Informational sidebar
;;; Code:
(local awful (require :awful))
(local beautiful (require :beautiful))
(local gears (require :gears))
(local dpi beautiful.xresources.apply_dpi)
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))
(local button (. (require :lib.keys) :button))
2019-01-15 16:33:58 +11:00
(local tag-list (require :widget.tag-list))
2019-01-16 00:23:31 +11:00
(local tag-number (require :widget.tag-number))
(local task-list (require :widget.task-list))
(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
(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})
(fn deftooltip [obj callback]
(awful.tooltip
{:objects [obj]
:timer_function callback
:delay_show 0.5
:margin_leftright (dpi 10)
:margin_topbottom (dpi 8)}))
2019-01-15 17:24:06 +11:00
(local clock (textclock "%H\n%M"))
(local systray (doto (wibox.widget.systray)
(: :set_base_size 24)
(: :set_horizontal false)))
2019-01-15 17:01:14 +11:00
(local battery (require :widget.bat))
(local pulse (require :widget.pulse))
2019-01-15 11:20:10 +11:00
(local clock-buttons
(gears.table.join
(button [] 1 (lambda [] (awful.spawn "orage")))))
(fn bat-detail []
(let [status _G.bat_now.status
statustxt (if (= status "Full") "charged"
(= status "Charging") "charging"
(= status "Discharging") "discharging"
"N/A")]
(..
"Level: " _G.bat_now.perc "%\n"
"Status: " statustxt "\n"
(if (or (= status "Charging")
(= status "Discharging"))
(.. "Time left: " _G.bat_now.time " hours") ""))))
(deftooltip clock (lambda [] (os.date "%A %d %B %Y")))
(deftooltip battery.widget bat-detail)
(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-16 00:23:31 +11:00
1 {1 (border
{1 {1 (tag-number s)
:forced_height 32
:align :center
:widget wibox.container.place}
:bg beautiful.sidebar_bg_info
:widget wibox.container.background})
2 (border (tag-list s))
:layout wibox.layout.fixed.vertical}
2019-01-15 21:33:41 +11:00
2 {1 (border (center (task-list s)) 4)
:layout wibox.layout.flex.vertical}
2019-01-15 17:24:06 +11:00
3 {1 (center systray)
2 (center battery.widget)
2019-01-16 00:23:31 +11:00
3 (border
{1 {1 (center clock)
:top 3
:bottom 3
:widget wibox.container.margin}
:buttons clock-buttons
:bg beautiful.sidebar_bg_info
:widget wibox.container.background})
:layout wibox.layout.fixed.vertical}}))
2019-01-15 11:20:10 +11:00
;;;
;; Configuration
(awful.screen.connect_for_each_screen
draw-sidebar)
2019-01-15 11:20:10 +11:00
{}
;;; module/sidebar.fnl ends here