awesomewm/desktop/widgets/shortcut.lua

52 lines
1.1 KiB
Lua

local shortcuts = {}
function shortcuts:new(command, icon)
widget = wibox.widget {
{
{ -- Right space
widget = wibox.widget.separator,
color = beautiful.color.transparent,
forced_width = beautiful.dpi(3)
},
{
wibox.widget {
resize = true,
image = conf.app_icon_dir .. icon,
widget = wibox.widget.imagebox
},
top = beautiful.dpi(3),
bottom = beautiful.dpi(3),
layout = wibox.container.margin,
},
{ -- Left space
widget = wibox.widget.separator,
color = beautiful.color.transparent,
forced_width = beautiful.dpi(3)
},
layout = wibox.layout.align.horizontal,
},
layout = wibox.container.background
}
widget:connect_signal("mouse::enter", function(result)
result.bg = beautiful.color.bar.hover_bg
end)
widget:connect_signal("mouse::leave", function(result)
result.bg = beautiful.color.transparent
end)
widget:connect_signal("button::press",
function(_, _, _, button, mods)
if (button == 1) then
awful.spawn(command, false)
end
end
)
return widget
end
return shortcuts