refactor(sidebar): abstract tooltips into function

This commit is contained in:
xeals 2019-01-15 22:58:30 +11:00
parent 0bbff9ba62
commit 3017ac7e16

View File

@ -36,6 +36,14 @@
: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)}))
(local clock (textclock "%H\n%M"))
(local systray (doto (wibox.widget.systray)
(: :set_base_size 24)
@ -48,12 +56,6 @@
(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"
@ -67,11 +69,8 @@
(= 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)})
(deftooltip clock (lambda [] (os.date "%A %d %B %Y")))
(deftooltip battery.widget bat-detail)
(fn draw-sidebar [s]
(set s.sb (awful.wibar {:position beautiful.sidebar_position