highlighed pressed widget
This commit is contained in:
parent
6489e7ede4
commit
fa6a9c171a
113
init.lua
113
init.lua
|
@ -16,8 +16,9 @@ local noobie_widget = {}
|
||||||
local noobie_popup = awful.popup{
|
local noobie_popup = awful.popup{
|
||||||
ontop = true,
|
ontop = true,
|
||||||
visible = false,
|
visible = false,
|
||||||
shape = gears.shape.rounded_rect,
|
shape = function(cr, width, height)
|
||||||
border_width = 1,
|
gears.shape.rounded_rect(cr, width, height, 4)
|
||||||
|
end, border_width = 1,
|
||||||
border_color = beautiful.bg_focus,
|
border_color = beautiful.bg_focus,
|
||||||
maximum_width = 400,
|
maximum_width = 400,
|
||||||
offset = { y = 5 },
|
offset = { y = 5 },
|
||||||
|
@ -27,25 +28,36 @@ local noobie_popup = awful.popup{
|
||||||
local function worker(user_args)
|
local function worker(user_args)
|
||||||
local args = user_args or {}
|
local args = user_args or {}
|
||||||
local path = args.path
|
local path = args.path
|
||||||
|
local refresh_rate = args.refresh_rate or 600
|
||||||
|
|
||||||
noobie_widget = wibox.widget {
|
noobie_widget = wibox.widget {
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
id = 'icn',
|
{
|
||||||
forced_height = 20,
|
{
|
||||||
forced_width = 20,
|
id = 'icn',
|
||||||
resize = true,
|
forced_height = 20,
|
||||||
widget = wibox.widget.imagebox
|
forced_width = 20,
|
||||||
|
resize = true,
|
||||||
|
widget = wibox.widget.imagebox
|
||||||
|
},
|
||||||
|
valign = 'center',
|
||||||
|
layout = wibox.container.place
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id = 'txt',
|
||||||
|
widget = wibox.widget.textbox
|
||||||
|
},
|
||||||
|
spacing = 4,
|
||||||
|
layout = wibox.layout.fixed.horizontal
|
||||||
},
|
},
|
||||||
valign = 'center',
|
margins = 4,
|
||||||
layout = wibox.container.place
|
widget = wibox.container.margin
|
||||||
},
|
},
|
||||||
{
|
shape = function(cr, width, height)
|
||||||
id = 'txt',
|
gears.shape.rounded_rect(cr, width, height, 4)
|
||||||
widget = wibox.widget.textbox
|
end,
|
||||||
},
|
widget = wibox.container.background,
|
||||||
spacing = 4,
|
|
||||||
layout = wibox.layout.fixed.horizontal,
|
|
||||||
set_text = function(self, new_text)
|
set_text = function(self, new_text)
|
||||||
self:get_children_by_id('txt')[1]:set_text(new_text)
|
self:get_children_by_id('txt')[1]:set_text(new_text)
|
||||||
end,
|
end,
|
||||||
|
@ -60,46 +72,49 @@ local function worker(user_args)
|
||||||
widget:set_text(result.widget.text)
|
widget:set_text(result.widget.text)
|
||||||
widget:set_icon(result.widget.icon_path)
|
widget:set_icon(result.widget.icon_path)
|
||||||
|
|
||||||
local rows = {
|
if result.menu ~=nil and result.menu.items ~= nil and #result.menu.items > 0 then
|
||||||
{ widget = wibox.widget.textbox },
|
|
||||||
layout = wibox.layout.fixed.vertical,
|
|
||||||
}
|
|
||||||
|
|
||||||
for i = 0, #rows do rows[i]=nil end
|
local rows = {
|
||||||
for _, item in ipairs(result.menu.items) do
|
{ widget = wibox.widget.textbox },
|
||||||
local row = wibox.widget {
|
layout = wibox.layout.fixed.vertical,
|
||||||
{
|
}
|
||||||
|
|
||||||
|
for i = 0, #rows do rows[i]=nil end
|
||||||
|
for _, item in ipairs(result.menu.items) do
|
||||||
|
local row = wibox.widget {
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
image = ICONS_DIR .. item.icon .. '.svg',
|
{
|
||||||
resize = true,
|
image = ICONS_DIR .. item.icon .. '.svg',
|
||||||
forced_height = 20,
|
resize = true,
|
||||||
forced_width = 20,
|
forced_height = 20,
|
||||||
widget = wibox.widget.imagebox
|
forced_width = 20,
|
||||||
|
widget = wibox.widget.imagebox
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text = item.title,
|
||||||
|
font = font,
|
||||||
|
widget = wibox.widget.textbox
|
||||||
|
},
|
||||||
|
spacing = 12,
|
||||||
|
layout = wibox.layout.fixed.horizontal
|
||||||
},
|
},
|
||||||
{
|
margins = 8,
|
||||||
text = item.title,
|
layout = wibox.container.margin
|
||||||
font = font,
|
|
||||||
widget = wibox.widget.textbox
|
|
||||||
},
|
|
||||||
spacing = 12,
|
|
||||||
layout = wibox.layout.fixed.horizontal
|
|
||||||
},
|
},
|
||||||
margins = 8,
|
bg = beautiful.bg_normal,
|
||||||
layout = wibox.container.margin
|
widget = wibox.container.background
|
||||||
},
|
}
|
||||||
bg = beautiful.bg_normal,
|
row:connect_signal("mouse::enter", function(c) c:set_bg(beautiful.bg_focus) end)
|
||||||
widget = wibox.container.background
|
row:connect_signal("mouse::leave", function(c) c:set_bg(beautiful.bg_normal) end)
|
||||||
}
|
|
||||||
row:connect_signal("mouse::enter", function(c) c:set_bg(beautiful.bg_focus) end)
|
table.insert(rows, row)
|
||||||
row:connect_signal("mouse::leave", function(c) c:set_bg(beautiful.bg_normal) end)
|
end
|
||||||
|
|
||||||
|
noobie_popup:setup(rows)
|
||||||
|
|
||||||
table.insert(rows, row)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
noobie_popup:setup(rows)
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,15 +122,17 @@ local function worker(user_args)
|
||||||
awful.util.table.join(
|
awful.util.table.join(
|
||||||
awful.button({}, 1, function()
|
awful.button({}, 1, function()
|
||||||
if noobie_popup.visible then
|
if noobie_popup.visible then
|
||||||
|
noobie_widget:set_bg('#00000000')
|
||||||
noobie_popup.visible = not noobie_popup.visible
|
noobie_popup.visible = not noobie_popup.visible
|
||||||
else
|
else
|
||||||
|
noobie_widget:set_bg(beautiful.bg_focus)
|
||||||
noobie_popup:move_next_to(mouse.current_widget_geometry)
|
noobie_popup:move_next_to(mouse.current_widget_geometry)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
watch(string.format([[sh -c "%s"]], args.path), 10, update_widget, noobie_widget)
|
watch(string.format([[sh -c "%s"]], args.path), refresh_rate, update_widget, noobie_widget)
|
||||||
|
|
||||||
return noobie_widget
|
return noobie_widget
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue