refactor(sidebar): abstract tooltips into function
This commit is contained in:
parent
0bbff9ba62
commit
3017ac7e16
@ -36,6 +36,14 @@
|
|||||||
:align "center"
|
:align "center"
|
||||||
:widget wibox.container.place})
|
: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 clock (textclock "%H\n%M"))
|
||||||
(local systray (doto (wibox.widget.systray)
|
(local systray (doto (wibox.widget.systray)
|
||||||
(: :set_base_size 24)
|
(: :set_base_size 24)
|
||||||
@ -48,12 +56,6 @@
|
|||||||
(gears.table.join
|
(gears.table.join
|
||||||
(button [] 1 (lambda [] (awful.spawn "orage")))))
|
(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 []
|
(fn bat-detail []
|
||||||
(let [status _G.bat_now.status
|
(let [status _G.bat_now.status
|
||||||
statustxt (if (= status "Full") "charged"
|
statustxt (if (= status "Full") "charged"
|
||||||
@ -67,11 +69,8 @@
|
|||||||
(= status "Discharging"))
|
(= status "Discharging"))
|
||||||
(.. "Time left: " _G.bat_now.time " hours") ""))))
|
(.. "Time left: " _G.bat_now.time " hours") ""))))
|
||||||
|
|
||||||
(awful.tooltip {:objects [battery.widget]
|
(deftooltip clock (lambda [] (os.date "%A %d %B %Y")))
|
||||||
:timer_function bat-detail
|
(deftooltip battery.widget bat-detail)
|
||||||
:delay_show 0.5
|
|
||||||
:margin_leftright (dpi 10)
|
|
||||||
:margin_topbottom (dpi 8)})
|
|
||||||
|
|
||||||
(fn draw-sidebar [s]
|
(fn draw-sidebar [s]
|
||||||
(set s.sb (awful.wibar {:position beautiful.sidebar_position
|
(set s.sb (awful.wibar {:position beautiful.sidebar_position
|
||||||
|
Loading…
Reference in New Issue
Block a user