From 7d674d9b9022d233b5029d4e10bc83975fce8758 Mon Sep 17 00:00:00 2001 From: streetturtle Date: Sat, 19 Jun 2021 20:46:04 -0400 Subject: [PATCH] small refactoring --- README.md | 2 -- example.json | 2 +- init.lua | 8 ++++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 065c57f..027927d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # noobie -Still under development! - This is a widget-maker tool - it creates a widget based on a JSON definition returned by a script. For example, if your script returns following JSON: diff --git a/example.json b/example.json index 391291c..fcc1756 100644 --- a/example.json +++ b/example.json @@ -12,7 +12,7 @@ "items": [ { "icon": "https://avatars.githubusercontent.com/u/9363150?v=4", - "icon_height": 40, + "icon_size": 40, "title": "Say hi!", "onclick": "notify-send 'hi!'" }, diff --git a/init.lua b/init.lua index d7d6de3..870ce10 100644 --- a/init.lua +++ b/init.lua @@ -15,6 +15,7 @@ local WIDGET_DIR = HOME_DIR .. '/.config/awesome/noobie' local ICONS_DIR = WIDGET_DIR .. '/feather_icons/' local CACHE_DIR = os.getenv("HOME") .. '/.cache/noobie/icons' + local cur_stdout local noobie_widget = {} @@ -25,6 +26,7 @@ local function show_warning(message) text = message} end + local function worker(user_args) local args = user_args or {} local refresh_rate = args.refresh_rate or 600 @@ -106,13 +108,11 @@ local function worker(user_args) 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 + -- 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 local download_cmd = string.format([[sh -c "curl -n --create-dirs -o %s %s"]], icon_path, new_icon) - print(download_cmd) spawn.easy_async(download_cmd, function() self:get_children_by_id('icn')[1]:set_image(icon_path) end) else @@ -182,7 +182,7 @@ local function worker(user_args) ) end - widget:buttons(gears.table.join(mouse_actions_buttons, menu_buttons)) + widget:buttons(gears.table.join(mouse_actions_buttons, menu_buttons)) end watch(string.format([[sh -c "%s"]], path), refresh_rate, update_widget, noobie_widget)