From 07e372b31cc7e1da975c7d08bd7bce8d2befe660 Mon Sep 17 00:00:00 2001 From: xeals Date: Tue, 15 Jan 2019 22:51:07 +1100 Subject: [PATCH] feat(sidebar): add buttons and tooltips --- module/sidebar.fnl | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/module/sidebar.fnl b/module/sidebar.fnl index eab3939..ee60f2c 100644 --- a/module/sidebar.fnl +++ b/module/sidebar.fnl @@ -4,10 +4,13 @@ (local awful (require :awful)) (local beautiful (require :beautiful)) +(local gears (require :gears)) +(local dpi beautiful.xresources.apply_dpi) (local lain (require :lain)) (local wibox (require :wibox)) (local std (require :lib.std)) +(local button (. (require :lib.keys) :button)) (local tag-list (require :widget.tag-list)) (local task-list (require :widget.task-list)) @@ -41,6 +44,35 @@ (local battery (require :widget.bat)) (local pulse (require :widget.pulse)) +(local clock-buttons + (gears.table.join + (button [] 1 (lambda [] (awful.spawn "orage"))))) + +(awful.tooltip {:objects [clock] + :timer_function (lambda [] (os.date "%A %d %B %Y")) + :delay_show 0.5 + :margin_leftright (dpi 10) + :margin_topbottom (dpi 8)}) + +(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") "")))) + +(awful.tooltip {:objects [battery.widget] + :timer_function bat-detail + :delay_show 0.5 + :margin_leftright (dpi 10) + :margin_topbottom (dpi 8)}) + (fn draw-sidebar [s] (set s.sb (awful.wibar {:position beautiful.sidebar_position :width beautiful.sidebar_width @@ -61,6 +93,7 @@ :widget wibox.container.margin} :widget wibox.container.background :bg beautiful.sidebar_bg_info}) + :buttons clock-buttons :layout wibox.layout.fixed.vertical} :layout wibox.layout.fixed.vertical}}))