reorganization
This commit is contained in:
17
main/actions-widget.lua
Normal file
17
main/actions-widget.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
-- name = "Actions"
|
||||
-- description = "Launcher actions widget"
|
||||
-- type = "widget"
|
||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||
-- version = "1.0"
|
||||
|
||||
function on_resume()
|
||||
actions_names = { "Drawer", "Search", "Notify", "Menu" }
|
||||
actions_colors = { md_colors.purple_800, md_colors.purple_600, md_colors.purple_400, md_colors.purple_300 }
|
||||
actions = { "apps_menu", "search", "notify", "quick_menu" }
|
||||
|
||||
ui:show_buttons(actions_names, actions_colors)
|
||||
end
|
||||
|
||||
function on_click(idx)
|
||||
aio:do_action(actions[idx])
|
||||
end
|
||||
16
main/btc-widget.lua
Normal file
16
main/btc-widget.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
-- name = "Bitcoin price"
|
||||
-- description = "Current Bitcoin price (blockchain.info)"
|
||||
-- type = "widget"
|
||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||
-- version = "1.0"
|
||||
|
||||
equals = "<font color=\""..ui:get_secondary_text_color().."\"> = </font>"
|
||||
|
||||
function on_alarm()
|
||||
http:get("https://api.blockchain.info/ticker")
|
||||
end
|
||||
|
||||
function on_network_result(result)
|
||||
local price = ajson:get_value(result, "object object:USD string:last")
|
||||
ui:show_text("1 BTC"..equals..price.." USD")
|
||||
end
|
||||
9
main/clipboard-widget.lua
Normal file
9
main/clipboard-widget.lua
Normal file
@@ -0,0 +1,9 @@
|
||||
-- name = "Clipboard"
|
||||
-- description = "Shows current Clipboard contents"
|
||||
-- type = "widget"
|
||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||
-- version = "1.0"
|
||||
|
||||
function on_resume()
|
||||
ui:show_text(system:get_from_clipboard())
|
||||
end
|
||||
30
main/covid-widget.lua
Normal file
30
main/covid-widget.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
-- name = "Covid info"
|
||||
-- description = "Cases of illness and death from covid"
|
||||
-- data_source = "covid19api.com"
|
||||
-- type = "widget"
|
||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||
-- version = "1.0"
|
||||
|
||||
equals = "<font color=\""..ui:get_secondary_text_color().."\"> = </font>"
|
||||
|
||||
function on_alarm()
|
||||
http:get("https://api.covid19api.com/summary")
|
||||
end
|
||||
|
||||
function on_network_result(result)
|
||||
local new = ajson:get_value(result, "object object:Global int:NewConfirmed")
|
||||
local total = ajson:get_value(result, "object object:Global int:TotalConfirmed")
|
||||
local newDeaths = ajson:get_value(result, "object object:Global int:NewDeaths")
|
||||
local totalDeaths = ajson:get_value(result, "object object:Global int:TotalDeaths")
|
||||
|
||||
ui:show_lines({
|
||||
"<b>Disease</b> | total"..equals..comma_value(total).." | new"..equals..comma_value(new),
|
||||
"<b>Deaths</b> | total"..equals..comma_value(totalDeaths).." | new"..equals..comma_value(newDeaths)
|
||||
})
|
||||
end
|
||||
|
||||
function comma_value(n) -- credit http://richard.warburton.it
|
||||
local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
|
||||
return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right
|
||||
end
|
||||
|
||||
105
main/currencies-widget.lua
Normal file
105
main/currencies-widget.lua
Normal file
@@ -0,0 +1,105 @@
|
||||
-- name = "Currencies"
|
||||
-- description = "Currency rates widget. Click on the date to change it."
|
||||
-- data_source = "https://github.com/fawazahmed0/currency-api#readme"
|
||||
-- type = "widget"
|
||||
-- author = "Andrey Gavrilov"
|
||||
-- version = "1.0"
|
||||
-- arguments_help = "Enter the list of currency pairs in the format usd:rub btc:usd"
|
||||
-- arguments_default = "usd:rub eur:rub"
|
||||
|
||||
json = require "json"
|
||||
|
||||
-- constants
|
||||
local red_color = "#f44336"
|
||||
local green_color = "#48ad47"
|
||||
local text_color = ui:get_secondary_text_color()
|
||||
local equals = "<font color=\""..text_color.."\"> = </font>"
|
||||
|
||||
-- global vars
|
||||
local result_curr = ""
|
||||
local tabl = {}
|
||||
|
||||
function on_resume()
|
||||
ui:set_folding_flag(true)
|
||||
ui:show_lines(tabl)
|
||||
end
|
||||
|
||||
function on_alarm()
|
||||
get_rates("latest", "curr")
|
||||
end
|
||||
|
||||
function get_rates(loc_date,id)
|
||||
http:get("https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/"..loc_date.."/currencies/usd.json",id)
|
||||
end
|
||||
|
||||
function on_network_result_curr(result)
|
||||
result_curr = result
|
||||
|
||||
local t = json.decode(result)
|
||||
local dat = t.date
|
||||
local prev_date = prev_date(dat)
|
||||
|
||||
get_rates(prev_date, "prev")
|
||||
end
|
||||
|
||||
function on_network_result_prev(result)
|
||||
tabl = create_tab(result)
|
||||
ui:show_lines(tabl)
|
||||
end
|
||||
|
||||
function on_click(idx)
|
||||
ui:show_edit_dialog("Введите дату курсов", "Введите дату курсов в формате 2020.12.31. Пустое значение - текущая дата.")
|
||||
end
|
||||
|
||||
function on_dialog_action(dat)
|
||||
if dat == "" then dat = "latest" end
|
||||
get_rates(dat:gsub(".", "-"), "curr")
|
||||
end
|
||||
|
||||
function prev_date(dat)
|
||||
local prev_date = dat:split("-")
|
||||
local prev_time = os.time{year=prev_date[1], month=prev_date[2], day=prev_date[3]} - (60*60*24)
|
||||
return os.date("%Y-%m-%d", prev_time)
|
||||
end
|
||||
|
||||
function create_tab(result)
|
||||
local curs = aio:get_args()
|
||||
local tab = {}
|
||||
local t_c = json.decode(result_curr)
|
||||
local t_p = json.decode(result)
|
||||
|
||||
-- set title
|
||||
local dat = t_c.date
|
||||
ui:set_title(ui:get_default_title().." "..dat:gsub("-", "."))
|
||||
|
||||
for idx = 1, #curs, 1 do
|
||||
local cur = curs[idx]:split(":")
|
||||
|
||||
local rate_curr1 = t_c.usd[cur[1]]
|
||||
local rate_curr2 = t_c.usd[cur[2]]
|
||||
local rate_prev1 = t_p.usd[cur[1]]
|
||||
local rate_prev2 = t_p.usd[cur[2]]
|
||||
|
||||
local rate_curr = round(rate_curr2/rate_curr1, 4)
|
||||
local rate_prev = round(rate_prev2/rate_prev1, 4)
|
||||
local change = round((rate_curr-rate_prev)/rate_prev*100,2)
|
||||
|
||||
local line = "1 "..string.upper(cur[1])..equals..rate_curr.." "..string.upper(cur[2])
|
||||
line = line..get_formatted_change_text(change)
|
||||
|
||||
table.insert(tab, line)
|
||||
end
|
||||
return tab
|
||||
end
|
||||
|
||||
-- utils --
|
||||
|
||||
function get_formatted_change_text(change)
|
||||
if change > 0 then
|
||||
return "<font color=\""..green_color.."\"><small> +"..change.."%</small></font>"
|
||||
elseif change < 0 then
|
||||
return "<font color=\""..red_color.."\"><small> "..change.."%</small></font>"
|
||||
else
|
||||
return "<font color=\""..text_color.."\"><small> "..change.."%</small></font>"
|
||||
end
|
||||
end
|
||||
35
main/github-trending-widget.lua
Normal file
35
main/github-trending-widget.lua
Normal file
@@ -0,0 +1,35 @@
|
||||
-- name = "GitHub Trending"
|
||||
-- description = "GitHub trending repositories (trending-github.com)"
|
||||
-- type = "widget"
|
||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||
-- version = "1.0"
|
||||
|
||||
function on_alarm()
|
||||
http:get("https://api.trending-github.com/github/repositories")
|
||||
end
|
||||
|
||||
function on_network_result(result)
|
||||
local names = {
|
||||
ajson:get_value(result, "array object:0 string:name"),
|
||||
ajson:get_value(result, "array object:1 string:name"),
|
||||
ajson:get_value(result, "array object:2 string:name"),
|
||||
}
|
||||
|
||||
local descriptions = {
|
||||
ajson:get_value(result, "array object:0 string:description"),
|
||||
ajson:get_value(result, "array object:1 string:description"),
|
||||
ajson:get_value(result, "array object:2 string:description"),
|
||||
}
|
||||
|
||||
urls = {
|
||||
ajson:get_value(result, "array object:0 string:url"),
|
||||
ajson:get_value(result, "array object:1 string:url"),
|
||||
ajson:get_value(result, "array object:2 string:url"),
|
||||
}
|
||||
|
||||
ui:show_lines(names, descriptions)
|
||||
end
|
||||
|
||||
function on_click(idx)
|
||||
system:open_browser(urls[idx])
|
||||
end
|
||||
15
main/icndb-widget.lua
Normal file
15
main/icndb-widget.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
-- name = "Chuck Norris jokes"
|
||||
-- description = "icndb.com"
|
||||
-- data_source = "icndb.com"
|
||||
-- type = "widget"
|
||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||
-- version = "1.0"
|
||||
|
||||
function on_alarm()
|
||||
http:get("http://api.icndb.com/jokes/random")
|
||||
end
|
||||
|
||||
function on_network_result(result)
|
||||
local joke = ajson:get_value(result, "object object:value string:joke")
|
||||
ui:show_text(joke)
|
||||
end
|
||||
17
main/inspiration-quotes-widget.lua
Normal file
17
main/inspiration-quotes-widget.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
-- name = "Inspiration quotes"
|
||||
-- description = "inspiration.goprogram.ai"
|
||||
-- data_source = "inspiration.goprogram.ai"
|
||||
-- type = "widget"
|
||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||
-- version = "1.0"
|
||||
|
||||
function on_alarm()
|
||||
http:get("https://inspiration.goprogram.ai/")
|
||||
end
|
||||
|
||||
function on_network_result(result)
|
||||
local quote = ajson:get_value(result, "object string:quote")
|
||||
local author = ajson:get_value(result, "object string:author")
|
||||
|
||||
ui:show_lines({ quote }, { author })
|
||||
end
|
||||
14
main/public-ip-widget.lua
Normal file
14
main/public-ip-widget.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
-- name = "Public IP"
|
||||
-- description = "Shows your public IP (ipify.org)"
|
||||
-- data_source = "ipify.org"
|
||||
-- type = "widget"
|
||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||
-- version = "1.0"
|
||||
|
||||
function on_alarm()
|
||||
http:get("https://api.ipify.org")
|
||||
end
|
||||
|
||||
function on_network_result(result)
|
||||
ui:show_text(result)
|
||||
end
|
||||
17
main/quotes-widget.lua
Normal file
17
main/quotes-widget.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
-- name = "Random quotes"
|
||||
-- description = "quotable.io"
|
||||
-- data_source = "quotable.io"
|
||||
-- type = "widget"
|
||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||
-- version = "1.0"
|
||||
|
||||
function on_alarm()
|
||||
http:get("https://api.quotable.io/random")
|
||||
end
|
||||
|
||||
function on_network_result(result)
|
||||
local quote = ajson:get_value(result, "object string:content")
|
||||
local author = ajson:get_value(result, "object string:author")
|
||||
|
||||
ui:show_lines({ quote }, { author })
|
||||
end
|
||||
16
main/random-joke-widget.lua
Normal file
16
main/random-joke-widget.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
-- name = "Random jokes"
|
||||
-- description = "official-joke-api.appspot.com"
|
||||
-- data_source = "official-joke-api.appspot.com"
|
||||
-- type = "widget"
|
||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||
-- version = "1.0"
|
||||
|
||||
function on_alarm()
|
||||
http:get("https://official-joke-api.appspot.com/random_joke")
|
||||
end
|
||||
|
||||
function on_network_result(result)
|
||||
local setup = ajson:get_value(result, "object string:setup")
|
||||
local punchline = ajson:get_value(result, "object string:punchline")
|
||||
ui:show_lines({setup, punchline})
|
||||
end
|
||||
54
main/rss-widget.lua
Normal file
54
main/rss-widget.lua
Normal file
@@ -0,0 +1,54 @@
|
||||
-- name = "News"
|
||||
-- description = "Simple RSS news widget"
|
||||
-- data_source = "https://rss-to-json-serverless-api.vercel.app/"
|
||||
-- type = "widget"
|
||||
-- author = "Andrey Gavrilov"
|
||||
-- version = "1.0"
|
||||
|
||||
-- settings
|
||||
local feed = "https://news.yandex.ru/index.rss"
|
||||
local lines_num = 5
|
||||
local auto_folding = false
|
||||
|
||||
local api_url = "https://rss-to-json-serverless-api.vercel.app/api?feedURL="
|
||||
local titles = {}
|
||||
local descs = {}
|
||||
local urls = {}
|
||||
local times = {}
|
||||
local url = ""
|
||||
|
||||
local json = require "json"
|
||||
|
||||
function on_resume()
|
||||
if auto_folding then
|
||||
ui:set_folding_flag(true)
|
||||
ui:show_lines(titles)
|
||||
end
|
||||
end
|
||||
|
||||
function on_alarm()
|
||||
http:get(api_url..feed)
|
||||
end
|
||||
|
||||
function on_network_result(result)
|
||||
local t = json.decode(result)
|
||||
local n = math.min(lines_num, #t.items)
|
||||
for i = 1, n, 1 do
|
||||
titles[i] = t.items[i].title
|
||||
descs[i] = t.items[i].description
|
||||
urls[i] = t.items[i].url
|
||||
times[i] = os.date("%d.%m.%Y, %H:%M",t.items[i].created/1000)
|
||||
end
|
||||
ui:show_lines(titles)
|
||||
end
|
||||
|
||||
function on_click(i)
|
||||
url = urls[i]
|
||||
ui:show_dialog(titles[i].." | "..times[i], descs[i], "open in browser")
|
||||
end
|
||||
|
||||
function on_dialog_action(i)
|
||||
if i == 1 then
|
||||
system:open_browser(url)
|
||||
end
|
||||
end
|
||||
29
main/shell-widget.lua
Normal file
29
main/shell-widget.lua
Normal file
@@ -0,0 +1,29 @@
|
||||
-- name = "Shell widget"
|
||||
-- description = "Shows the result of executing console commands"
|
||||
-- type = "widget"
|
||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||
-- version = "1.0"
|
||||
|
||||
current_output = "Click to enter command"
|
||||
|
||||
function on_resume()
|
||||
redraw()
|
||||
end
|
||||
|
||||
function redraw()
|
||||
ui:show_text(current_output)
|
||||
end
|
||||
|
||||
function on_click(idx)
|
||||
ui:show_edit_dialog("Enter command")
|
||||
end
|
||||
|
||||
function on_dialog_action(text)
|
||||
system:exec(text)
|
||||
end
|
||||
|
||||
function on_shell_result(text)
|
||||
current_output = text
|
||||
redraw()
|
||||
end
|
||||
|
||||
12
main/year_progress-widget.lua
Normal file
12
main/year_progress-widget.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
-- name = "Year progress"
|
||||
-- description = "Shows current year progress"
|
||||
-- type = "widget"
|
||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||
-- version = "1.0"
|
||||
|
||||
function on_resume()
|
||||
local year_days = 365
|
||||
local current_day = os.date("*t").yday
|
||||
local percent = math.floor(current_day / (year_days / 100))
|
||||
ui:show_progress_bar("Year progress: "..percent.."%", current_day, year_days)
|
||||
end
|
||||
Reference in New Issue
Block a user