Cleaned up shortcut code
This commit is contained in:
@ -1,7 +1,14 @@
|
||||
local shortcuts = {}
|
||||
local P = {}
|
||||
P.__index = P
|
||||
|
||||
function shortcuts:new(command, icon)
|
||||
widget = wibox.widget {
|
||||
function P:new(args)
|
||||
local s = {
|
||||
command = args.command,
|
||||
icon = args.icon
|
||||
}
|
||||
setmetatable(s, self)
|
||||
|
||||
s.widget = wibox.widget {
|
||||
{
|
||||
{ -- Right space
|
||||
widget = wibox.widget.separator,
|
||||
@ -11,7 +18,7 @@ function shortcuts:new(command, icon)
|
||||
{
|
||||
wibox.widget {
|
||||
resize = true,
|
||||
image = conf.app_icon_dir .. icon,
|
||||
image = conf.app_icon_dir .. s.icon,
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
top = beautiful.dpi(3),
|
||||
@ -28,24 +35,24 @@ function shortcuts:new(command, icon)
|
||||
layout = wibox.container.background
|
||||
}
|
||||
|
||||
widget:connect_signal("mouse::enter", function(result)
|
||||
s.widget:connect_signal("mouse::enter", function(result)
|
||||
result.bg = beautiful.color.bar.hover_bg
|
||||
end)
|
||||
|
||||
widget:connect_signal("mouse::leave", function(result)
|
||||
s.widget:connect_signal("mouse::leave", function(result)
|
||||
result.bg = beautiful.color.transparent
|
||||
end)
|
||||
|
||||
|
||||
widget:connect_signal("button::press",
|
||||
s.widget:connect_signal("button::press",
|
||||
function(_, _, _, button, mods)
|
||||
if (button == 1) then
|
||||
awful.spawn(command, false)
|
||||
awful.spawn(s.command, false)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
return widget
|
||||
return s
|
||||
end
|
||||
|
||||
return shortcuts
|
||||
return P
|
||||
|
Reference in New Issue
Block a user