diff --git a/README.md b/README.md index 6a34585..065c57f 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/example.json b/example.json index 9a238eb..391291c 100644 --- a/example.json +++ b/example.json @@ -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" } ] } diff --git a/init.lua b/init.lua index 8bae49e..d7d6de3 100644 --- a/init.lua +++ b/init.lua @@ -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 diff --git a/row_builder.lua b/row_builder.lua index d7623e0..a8ffef2 100644 --- a/row_builder.lua +++ b/row_builder.lua @@ -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',