small refactoring
This commit is contained in:
parent
0b5abd87ea
commit
7d674d9b90
|
@ -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:
|
||||
|
||||
|
|
|
@ -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!'"
|
||||
},
|
||||
|
|
4
init.lua
4
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
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue