small refactoring
This commit is contained in:
parent
0b5abd87ea
commit
7d674d9b90
|
@ -1,7 +1,5 @@
|
||||||
# noobie
|
# noobie
|
||||||
|
|
||||||
Still under development!
|
|
||||||
|
|
||||||
This is a widget-maker tool - it creates a widget based on a JSON definition returned by a script.
|
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:
|
For example, if your script returns following JSON:
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"icon": "https://avatars.githubusercontent.com/u/9363150?v=4",
|
"icon": "https://avatars.githubusercontent.com/u/9363150?v=4",
|
||||||
"icon_height": 40,
|
"icon_size": 40,
|
||||||
"title": "Say hi!",
|
"title": "Say hi!",
|
||||||
"onclick": "notify-send 'hi!'"
|
"onclick": "notify-send 'hi!'"
|
||||||
},
|
},
|
||||||
|
|
8
init.lua
8
init.lua
|
@ -15,6 +15,7 @@ local WIDGET_DIR = HOME_DIR .. '/.config/awesome/noobie'
|
||||||
local ICONS_DIR = WIDGET_DIR .. '/feather_icons/'
|
local ICONS_DIR = WIDGET_DIR .. '/feather_icons/'
|
||||||
local CACHE_DIR = os.getenv("HOME") .. '/.cache/noobie/icons'
|
local CACHE_DIR = os.getenv("HOME") .. '/.cache/noobie/icons'
|
||||||
|
|
||||||
|
|
||||||
local cur_stdout
|
local cur_stdout
|
||||||
local noobie_widget = {}
|
local noobie_widget = {}
|
||||||
|
|
||||||
|
@ -25,6 +26,7 @@ local function show_warning(message)
|
||||||
text = message}
|
text = message}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function worker(user_args)
|
local function worker(user_args)
|
||||||
local args = user_args or {}
|
local args = user_args or {}
|
||||||
local refresh_rate = args.refresh_rate or 600
|
local refresh_rate = args.refresh_rate or 600
|
||||||
|
@ -106,13 +108,11 @@ local function worker(user_args)
|
||||||
elseif new_icon:sub(1, 1) == '~' then
|
elseif new_icon:sub(1, 1) == '~' then
|
||||||
self:get_children_by_id('icn')[1]:set_image(HOME_DIR .. '/' .. new_icon:sub(3))
|
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
|
elseif new_icon:sub(1, 4) == 'http' then
|
||||||
local icon_path = CACHE_DIR .. '/' .. new_icon:sub(-16)
|
local icon_path = CACHE_DIR .. '/' .. new_icon:sub(-16)
|
||||||
if not gfs.file_readable(icon_path) then
|
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)
|
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,
|
spawn.easy_async(download_cmd,
|
||||||
function() self:get_children_by_id('icn')[1]:set_image(icon_path) end)
|
function() self:get_children_by_id('icn')[1]:set_image(icon_path) end)
|
||||||
else
|
else
|
||||||
|
@ -182,7 +182,7 @@ local function worker(user_args)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
widget:buttons(gears.table.join(mouse_actions_buttons, menu_buttons))
|
widget:buttons(gears.table.join(mouse_actions_buttons, menu_buttons))
|
||||||
end
|
end
|
||||||
|
|
||||||
watch(string.format([[sh -c "%s"]], path), refresh_rate, update_widget, noobie_widget)
|
watch(string.format([[sh -c "%s"]], path), refresh_rate, update_widget, noobie_widget)
|
||||||
|
|
Loading…
Reference in New Issue