awesomewm/desktop/widgets/shortcut.lua

59 lines
1.1 KiB
Lua
Raw Normal View History

2022-04-29 11:07:15 -07:00
local P = {}
P.__index = P
2021-08-01 07:24:26 -07:00
2022-04-29 11:07:15 -07:00
function P:new(args)
local s = {
command = args.command,
icon = args.icon
}
setmetatable(s, self)
s.widget = wibox.widget {
2021-08-01 07:24:26 -07:00
{
{ -- Right space
widget = wibox.widget.separator,
color = beautiful.color.transparent,
forced_width = beautiful.dpi(3)
},
{
wibox.widget {
resize = true,
2022-04-29 11:07:15 -07:00
image = conf.app_icon_dir .. s.icon,
2021-08-01 07:24:26 -07:00
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
}
2022-04-29 11:07:15 -07:00
s.widget:connect_signal("mouse::enter", function(result)
2021-08-01 07:24:26 -07:00
result.bg = beautiful.color.bar.hover_bg
end)
2022-04-29 11:07:15 -07:00
s.widget:connect_signal("mouse::leave", function(result)
2021-08-01 07:24:26 -07:00
result.bg = beautiful.color.transparent
end)
2022-04-29 11:07:15 -07:00
s.widget:connect_signal("button::press",
2021-08-01 07:24:26 -07:00
function(_, _, _, button, mods)
if (button == 1) then
2022-04-29 11:07:15 -07:00
awful.spawn(s.command, false)
2021-08-01 07:24:26 -07:00
end
end
)
2022-04-29 11:07:15 -07:00
return s
2021-08-01 07:24:26 -07:00
end
2022-04-29 11:07:15 -07:00
return P