improvements

This commit is contained in:
streetturtle 2021-04-30 22:17:47 -04:00
parent 9f0bba0c2c
commit 517906060e
3 changed files with 22 additions and 16 deletions

View File

@ -4,7 +4,7 @@ Still under development!
Create a wibar widget for Awesome WM with no lua code! Create a wibar widget for Awesome WM with no lua code!
This is widget-maker tool - it creates a widget based on a definition described in JSON format and returned by a script. This is a widget-maker tool - it creates a widget based on a definition described in JSON format and returned by a script.
For example, if your script returns a following JSON: For example, if your script returns a following JSON:
@ -26,7 +26,7 @@ noobie will convert it to following widget:
![screenshot](./screenshots/screenshot.png). ![screenshot](./screenshots/screenshot.png).
You can also create widgets with menu: You can also create widgets with a menu:
```json ```json
{ {
@ -63,19 +63,21 @@ You can also create widgets with menu:
gives: gives:
![](./screenshots/screenshot2.png) ![screenshot2](./screenshots/screenshot2.png)
## Features: ## Features:
- icon (either a widget or a menu item) can be one of: - icon (either of a widget or of a menu item) can be one of:
- a name of an icon from [feather icons](https://feathericons.com/): `arrow-down-circle`; - a name of an icon from [feather icons](https://feathericons.com/): `arrow-down-circle`;
- a path to a file: `/tmp/someicon.png; - a path to a file: `/tmp/someicon.png;
- a URL pointing to the icon: `http://some-icon.online/image.png`; - a URL pointing to the icon: `http://some-icon.online/image.png` (with a fallback icon);
- a notification with details in case your script failed:
![error notification](./screenshots/screenshot-errors.png)
## Plugins ## Plugins
You can create your own scripts in any language, the only rule is - it should return a proper JSON. Check out existing plugins in this repo: https://github.com/streetturtle/noobie-plugins.
Or you can check existing plugins in this repo: https://github.com/streetturtle/noobie-plugins.
## Installation ## Installation

View File

@ -39,19 +39,23 @@ local function build_icon_and_text_row(item, widget, noobie_popup)
if item.icon:sub(1, 1) == '/' then if item.icon:sub(1, 1) == '/' then
item_image:set_image(item.icon) item_image:set_image(item.icon)
-- new_icon is a url of the icon -- new_icon is a url of the icon
elseif item.icon:sub(1, 4) == 'http' then elseif item.icon:sub(1, 4) == 'http' then
local icon_path = CACHE_DIR .. '/' .. item.icon:sub(-16) local icon_path = CACHE_DIR .. '/' .. item.icon:sub(-16)
if not gfs.file_readable(icon_path) then if gfs.file_readable(icon_path) then
local download_cmd = string.format([[sh -c "curl -n --create-dirs -o %s %s"]], icon_path, item.icon)
print(download_cmd)
spawn.easy_async(download_cmd,
function() item_image:set_image(icon_path) end)
else
item_image:set_image(icon_path) item_image:set_image(icon_path)
else
local download_cmd = string.format([[sh -c "curl -L -f --create-dirs -o %s %s"]], icon_path, item.icon)
spawn.easy_async(download_cmd, function(stdout, stderr, reason, exit_code)
if (exit_code == 0) then
item_image:set_image(icon_path)
else
item_image:set_image(item.icon_fallback)
end
end)
end end
-- new_icon is a feather icon -- new_icon is a feather icon
else else
item_image:set_image(ICONS_DIR .. item.icon .. '.svg') item_image:set_image(ICONS_DIR .. item.icon .. '.svg')
end end

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB