local awful = require("awful") local wibox = require("wibox") local beautiful = require("beautiful") local gears = require("gears") -- TODO more args -- TODO use tooltip theme vars function create_wibox_tooltip(parent, widget) local p = { parent = parent, popup = awful.popup { widget = wibox.container.margin ( widget, beautiful.margin_leftright, beautiful.margin_leftright, beautiful.margin_topbottom, beautiful.margin_topbottom ), ontop = true, visible = false, preferred_positions = "bottom", preferred_anchors = "middle", } } -- hover timer p.timer = gears.timer { timeout = 1, single_shot = true, callback = function() p.popup:move_next_to(mouse.current_widget_geometry) p.popup.visible = true end, } -- signal functions p._mouse_enter = function() p.timer:again() end p._mouse_leave = function() p.timer:stop() p.popup.visible = false end p.connect_signals = function() p.parent:connect_signal("mouse::enter", p._mouse_enter) p.parent:connect_signal("mouse::leave", p._mouse_leave) end p.disconnect_signals = function() p.parent:disconnect_signal("mouse::enter", p._mouse_enter) p.parent:disconnect_signal("mouse::leave", p._mouse_leave) end p.connect_signals() return p end return create_wibox_tooltip