improvements

This commit is contained in:
streetturtle 2021-05-12 10:22:30 -04:00
parent 806489899e
commit 0b5abd87ea
4 changed files with 21 additions and 7 deletions

View File

@ -34,7 +34,7 @@ For more examples check out plugins repository: [noobie-plugins](https://github.
![menu](./screenshots/screenshot2.png)
- mouse actions (scroll up/down, right click);
- icon could be either a local file, a feathericons icon or an image from URL;
- icon could be either a local file, a [feathericons](https://feathericons.com/) icon or an image from URL;
- a notification with details in case your script failed:
![error notification](./screenshots/screenshot-errors.png)

View File

@ -21,16 +21,20 @@
"title": "Execute some script",
"onclick": "/tmp/somescript.sh"
},
{
"type": "header",
"title": "Header"
},
{
"icon": "slack",
"title": "OpenSlack",
"onclick": "xdg-open https://slack.com"
},
{
"title": "-"
"type" : "separator"
},
{
"title": "Menu item with no icon",
"title": "Menu item with no icon and no action"
}
]
}

View File

@ -102,7 +102,12 @@ local function worker(user_args)
if new_icon:sub(1, 1) == '/' then
self:get_children_by_id('icn')[1]:set_image(new_icon)
-- new_icon is a url to the icon
-- new_icon is a relative path to the file
elseif new_icon:sub(1, 1) == '~' then
self:get_children_by_id('icn')[1]:set_image(HOME_DIR .. '/' .. new_icon:sub(3))
-- new_icon is a url to the icon
elseif new_icon:sub(1, 4) == 'http' then
local icon_path = CACHE_DIR .. '/' .. new_icon:sub(-16)
if not gfs.file_readable(icon_path) then

View File

@ -35,10 +35,15 @@ local function build_icon_and_text_row(item, widget, noobie_popup)
widget = wibox.widget.imagebox
}
-- new_icon is a path to a file
-- new_icon is an absolute path to a file
if item.icon:sub(1, 1) == '/' then
item_image:set_image(item.icon)
-- new_icon is a relative path to the file
elseif item.icon:sub(1, 1) == '~' then
print(HOME_DIR .. '/' .. item.icon:sub(3))
item_image:set_image(HOME_DIR .. '/' .. item.icon:sub(3))
-- new_icon is a url of the icon
elseif item.icon:sub(1, 4) == 'http' then
local icon_path = CACHE_DIR .. '/' .. item.icon:sub(-16)
@ -130,11 +135,11 @@ end
function row_builder:build_row(item, widget, noobie_popup)
if item.header == true then
if item.type == 'header' then
return build_header_row(item)
elseif item.title ~= nil and #item.title > 0 and item.icon ~= nil and #item.icon > 0 then
return build_icon_and_text_row(item, widget, noobie_popup)
elseif item.title ~= nil and item.title == '-' then
elseif item.type == 'separator' then
return wibox.widget {
{
orientation = 'horizontal',