improvements
This commit is contained in:
parent
fa6a9c171a
commit
fcec9142ac
47
init.lua
47
init.lua
|
@ -18,7 +18,8 @@ local noobie_popup = awful.popup{
|
||||||
visible = false,
|
visible = false,
|
||||||
shape = function(cr, width, height)
|
shape = function(cr, width, height)
|
||||||
gears.shape.rounded_rect(cr, width, height, 4)
|
gears.shape.rounded_rect(cr, width, height, 4)
|
||||||
end, border_width = 1,
|
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 },
|
||||||
|
@ -30,6 +31,8 @@ local function worker(user_args)
|
||||||
local path = args.path
|
local path = args.path
|
||||||
local refresh_rate = args.refresh_rate or 600
|
local refresh_rate = args.refresh_rate or 600
|
||||||
|
|
||||||
|
local has_menu = false
|
||||||
|
|
||||||
noobie_widget = wibox.widget {
|
noobie_widget = wibox.widget {
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
@ -48,6 +51,7 @@ local function worker(user_args)
|
||||||
id = 'txt',
|
id = 'txt',
|
||||||
widget = wibox.widget.textbox
|
widget = wibox.widget.textbox
|
||||||
},
|
},
|
||||||
|
id = 'spc',
|
||||||
spacing = 4,
|
spacing = 4,
|
||||||
layout = wibox.layout.fixed.horizontal
|
layout = wibox.layout.fixed.horizontal
|
||||||
},
|
},
|
||||||
|
@ -59,11 +63,16 @@ local function worker(user_args)
|
||||||
end,
|
end,
|
||||||
widget = wibox.container.background,
|
widget = wibox.container.background,
|
||||||
set_text = function(self, new_text)
|
set_text = function(self, new_text)
|
||||||
|
if new_text == nil or new_text == '' then
|
||||||
|
self:get_children_by_id('txt')[1]:set_text('')
|
||||||
|
self:get_children_by_id('spc')[1]:set_spacing(0)
|
||||||
|
else
|
||||||
self:get_children_by_id('txt')[1]:set_text(new_text)
|
self:get_children_by_id('txt')[1]:set_text(new_text)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
set_icon = function(self, new_icon)
|
set_icon = function(self, new_icon)
|
||||||
self:get_children_by_id('icn')[1]:set_image(ICONS_DIR .. new_icon .. '.svg')
|
self:get_children_by_id('icn')[1]:set_image(ICONS_DIR .. new_icon .. '.svg')
|
||||||
end
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
local update_widget = function(widget, stdout, stderr)
|
local update_widget = function(widget, stdout, stderr)
|
||||||
|
@ -72,8 +81,9 @@ 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
|
has_menu = result.menu ~= nil and result.menu.items ~= nil and #result.menu.items > 0
|
||||||
|
|
||||||
|
if has_menu then
|
||||||
local rows = {
|
local rows = {
|
||||||
{ widget = wibox.widget.textbox },
|
{ widget = wibox.widget.textbox },
|
||||||
layout = wibox.layout.fixed.vertical,
|
layout = wibox.layout.fixed.vertical,
|
||||||
|
@ -105,8 +115,27 @@ local function worker(user_args)
|
||||||
bg = beautiful.bg_normal,
|
bg = beautiful.bg_normal,
|
||||||
widget = wibox.container.background
|
widget = wibox.container.background
|
||||||
}
|
}
|
||||||
row:connect_signal("mouse::enter", function(c) c:set_bg(beautiful.bg_focus) end)
|
|
||||||
row:connect_signal("mouse::leave", function(c) c:set_bg(beautiful.bg_normal) end)
|
local old_cursor, old_wibox
|
||||||
|
row:connect_signal("mouse::enter", function(c)
|
||||||
|
c:set_bg(beautiful.bg_focus)
|
||||||
|
local wb = mouse.current_wibox
|
||||||
|
old_cursor, old_wibox = wb.cursor, wb
|
||||||
|
wb.cursor = "hand1"
|
||||||
|
end)
|
||||||
|
row:connect_signal("mouse::leave", function(c)
|
||||||
|
c:set_bg(beautiful.bg_normal)
|
||||||
|
if old_wibox then
|
||||||
|
old_wibox.cursor = old_cursor
|
||||||
|
old_wibox = nil
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
row:buttons(awful.util.table.join(awful.button({}, 1, function()
|
||||||
|
awful.spawn.with_shell(item.onclick)
|
||||||
|
noobie_widget:set_bg('#00000000')
|
||||||
|
noobie_popup.visible = not noobie_popup.visible
|
||||||
|
end)))
|
||||||
|
|
||||||
table.insert(rows, row)
|
table.insert(rows, row)
|
||||||
end
|
end
|
||||||
|
@ -115,9 +144,7 @@ local function worker(user_args)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
if has_menu then
|
||||||
|
|
||||||
|
|
||||||
noobie_widget:buttons(
|
noobie_widget:buttons(
|
||||||
awful.util.table.join(
|
awful.util.table.join(
|
||||||
awful.button({}, 1, function()
|
awful.button({}, 1, function()
|
||||||
|
@ -131,6 +158,10 @@ local function worker(user_args)
|
||||||
end)
|
end)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
watch(string.format([[sh -c "%s"]], args.path), refresh_rate, update_widget, noobie_widget)
|
watch(string.format([[sh -c "%s"]], args.path), refresh_rate, update_widget, noobie_widget)
|
||||||
|
|
||||||
|
|
|
@ -28,3 +28,4 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue