highlighed pressed widget

This commit is contained in:
Pavel Makhov 2021-02-20 15:36:21 -05:00
parent 6489e7ede4
commit fa6a9c171a
1 changed files with 65 additions and 48 deletions

View File

@ -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,8 +28,11 @@ 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', id = 'icn',
@ -45,7 +49,15 @@ local function worker(user_args)
widget = wibox.widget.textbox widget = wibox.widget.textbox
}, },
spacing = 4, spacing = 4,
layout = wibox.layout.fixed.horizontal, layout = wibox.layout.fixed.horizontal
},
margins = 4,
widget = wibox.container.margin
},
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 4)
end,
widget = wibox.container.background,
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,6 +72,8 @@ 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)
if result.menu ~=nil and result.menu.items ~= nil and #result.menu.items > 0 then
local rows = { local rows = {
{ widget = wibox.widget.textbox }, { widget = wibox.widget.textbox },
layout = wibox.layout.fixed.vertical, layout = wibox.layout.fixed.vertical,
@ -99,6 +113,7 @@ local function worker(user_args)
noobie_popup:setup(rows) noobie_popup:setup(rows)
end
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