add many new scripts
This commit is contained in:
26
main/calendar-search.lua
Normal file
26
main/calendar-search.lua
Normal file
@@ -0,0 +1,26 @@
|
||||
-- name = "Calendar"
|
||||
-- description = "Calendar search script"
|
||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||
-- type = "search"
|
||||
|
||||
local events = calendar:get_events()
|
||||
local results = {}
|
||||
|
||||
function on_search(str)
|
||||
results = {}
|
||||
buttons = {}
|
||||
|
||||
for _,event in pairs(events) do
|
||||
if event.title:lower():find(str:lower()) ~= nil then
|
||||
table.insert(results, event)
|
||||
table.insert(buttons, event.title)
|
||||
end
|
||||
end
|
||||
|
||||
search:show(buttons)
|
||||
end
|
||||
|
||||
function on_click(idx)
|
||||
--calendar:show_event_dialog(results[idx].id)
|
||||
calendar:open_event(results[idx].id)
|
||||
end
|
||||
@@ -4,9 +4,10 @@
|
||||
-- type = "widget"
|
||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||
-- version = "1.0"
|
||||
-- foldable = "false"
|
||||
|
||||
function on_alarm()
|
||||
http:get("http://api.icndb.com/jokes/random")
|
||||
http:get("http://api.icndb.com/jokes/random")
|
||||
end
|
||||
|
||||
function on_network_result(result)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
-- type = "widget"
|
||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||
-- version = "1.0"
|
||||
-- foldable = "false"
|
||||
|
||||
function on_alarm()
|
||||
http:get("https://inspiration.goprogram.ai/")
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
-- name = "Kodi Remote"
|
||||
-- description = "Kodi multimedia center remote control widget"
|
||||
-- type = "widget"
|
||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||
-- arguments_help = "Enter the Kodi IP address and port in the following format: 192.168.0.102:8080"
|
||||
-- version = "1.1"
|
||||
|
||||
local colors = require "md_colors"
|
||||
local json = require "json"
|
||||
|
||||
-- constants
|
||||
|
||||
local media_type = "application/json"
|
||||
|
||||
local get_players_cmd = [[ { "id": 1, "jsonrpc": "2.0", "method": "Player.GetActivePlayers" } ]]
|
||||
local play_cmd = [[ {"jsonrpc": "2.0", "method": "Player.PlayPause", "params": { "playerid": XXX }, "id": 1} ]]
|
||||
local stop_cmd = [[ {"jsonrpc": "2.0", "method": "Player.Stop", "params": { "playerid": XXX }, "id": 1} ]]
|
||||
local prev_cmd = [[ {"jsonrpc": "2.0", "method": "Player.GoTo", "params": {"playerid": XXX,"to":"previous"}, "id":1} ]]
|
||||
local next_cmd = [[ {"jsonrpc": "2.0", "method": "Player.GoTo", "params": {"playerid": XXX,"to":"next"}, "id":1} ]]
|
||||
local forward_cmd = [[ {"jsonrpc": "2.0", "method": "Player.Seek", "params": { "playerid": XXX, "value": { "seconds": 300 } }, "id": 1} ]]
|
||||
local backward_cmd = [[ {"jsonrpc": "2.0", "method": "Player.Seek", "params": { "playerid": XXX, "value": { "seconds": -300 } }, "id": 1} ]]
|
||||
|
||||
local buttons = { "fa:fast-backward", "-5m", "fa:play", "fa:stop", "+5m", "fa:fast-forward", "Open Kore" }
|
||||
local buttons_cmds = { prev_cmd, backward_cmd, play_cmd, stop_cmd, forward_cmd, next_cmd }
|
||||
|
||||
-- global vars
|
||||
|
||||
local url = nil
|
||||
local curr_idx = nil
|
||||
|
||||
function on_resume()
|
||||
if next(settings:get()) == nil then
|
||||
ui:show_text("Tap to enter Kodi address")
|
||||
return
|
||||
end
|
||||
|
||||
init_url_from_settings()
|
||||
|
||||
ui:set_folding_flag(true)
|
||||
ui:show_buttons(buttons)
|
||||
end
|
||||
|
||||
function on_click(idx)
|
||||
if next(settings:get()) == nil then
|
||||
settings:show_dialog()
|
||||
return
|
||||
end
|
||||
|
||||
if (idx == 7) then
|
||||
apps:launch("org.xbmc.kore")
|
||||
return
|
||||
end
|
||||
|
||||
curr_idx = idx
|
||||
http:post(url, get_players_cmd, media_type, "players")
|
||||
end
|
||||
|
||||
function on_network_result_players(result)
|
||||
local parsed = json.decode(result)
|
||||
|
||||
if parsed.error ~= nil then
|
||||
show_error(parsed)
|
||||
return
|
||||
end
|
||||
|
||||
-- not playing anything
|
||||
if next(parsed.result) == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local player_id = parsed.result[1].playerid
|
||||
local cmd = buttons_cmds[curr_idx]:replace("XXX", player_id)
|
||||
|
||||
http:post(url, cmd, media_type, "cmd")
|
||||
|
||||
curr_idx = nil
|
||||
end
|
||||
|
||||
function on_network_result_cmd(result)
|
||||
local parsed = json.decode(result)
|
||||
|
||||
if parsed.error ~= nil then
|
||||
show_error(parsed)
|
||||
end
|
||||
end
|
||||
|
||||
-- utils
|
||||
|
||||
function init_url_from_settings()
|
||||
local ip_port = settings:get()[1]:split(":")
|
||||
url = "http://"..ip_port[1]..":"..ip_port[2].."/jsonrpc"
|
||||
end
|
||||
|
||||
function show_error(parsed)
|
||||
ui:show_toast("Error "..parsed.error.code..": "..parsed.error.message)
|
||||
end
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
-- type = "widget"
|
||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||
-- version = "1.0"
|
||||
-- foldable = "false"
|
||||
|
||||
function on_alarm()
|
||||
http:get("https://api.ipify.org")
|
||||
http:get("https://api.ipify.org")
|
||||
end
|
||||
|
||||
function on_network_result(result)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
-- type = "widget"
|
||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||
-- version = "1.0"
|
||||
-- foldable = "false"
|
||||
|
||||
function on_alarm()
|
||||
http:get("https://api.quotable.io/random")
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
-- type = "widget"
|
||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||
-- version = "1.0"
|
||||
-- foldable = "false"
|
||||
|
||||
current_output = "Click to enter command"
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
-- type = "widget"
|
||||
-- author = "Andrey Gavrilov"
|
||||
-- version = "1.0"
|
||||
-- foldable = "false"
|
||||
|
||||
local dialog_id = ""
|
||||
local unit = "length"
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
-- name = "Uptimerobot"
|
||||
-- description = "Shows uptime information from uptimerobot.com. Needs API key."
|
||||
-- data_source = "uptimerobot.com"
|
||||
-- type = "widget"
|
||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)
|
||||
-- version = "1.1"
|
||||
-- arguments_help = "Enter your API key"
|
||||
|
||||
local json = require "json"
|
||||
local md_colors = require "md_colors"
|
||||
|
||||
-- constants
|
||||
local api_url = "https://api.uptimerobot.com/v2/"
|
||||
local click_url = "https://uptimerobot.com/dashboard#mainDashboard"
|
||||
local media_type = "application/x-www-form-urlencoded"
|
||||
|
||||
function on_alarm()
|
||||
if (next(settings:get()) == nil) then
|
||||
ui:show_text("Tap to enter API key")
|
||||
return
|
||||
end
|
||||
|
||||
local key = settings:get()[1]
|
||||
local body = "api_key="..key.."&format=json"
|
||||
|
||||
http:post(api_url.."getMonitors", body, media_type)
|
||||
end
|
||||
|
||||
function on_click()
|
||||
if (next(settings:get()) == nil) then
|
||||
settings:show_dialog()
|
||||
else
|
||||
system:open_browser(click_url)
|
||||
end
|
||||
end
|
||||
|
||||
function on_network_result(result, code)
|
||||
if (code >= 400) then
|
||||
ui:show_text("Error: "..code)
|
||||
return
|
||||
end
|
||||
|
||||
local parsed = json.decode(result)
|
||||
|
||||
if (parsed.stat ~= "ok") then
|
||||
ui:show_text("Error: "..parsed.error.message)
|
||||
return
|
||||
end
|
||||
|
||||
local strings_tab = {}
|
||||
|
||||
for k,v in ipairs(parsed.monitors) do
|
||||
strings_tab[k] = v.friendly_name..": "..format_status(v.status)
|
||||
end
|
||||
|
||||
ui:show_table(table_to_tables(strings_tab, 2))
|
||||
end
|
||||
|
||||
-- utils
|
||||
|
||||
function format_status(status)
|
||||
local statuses = { "not checked", "up", "error", "error", "error", "error", "error", "seems down", "down" }
|
||||
local status_colors = { "yellow_500", "green_500", "red_500", "red_500", "red_500", "red_500", "red_500", "orange_500", "red_500" }
|
||||
|
||||
return "<font color=\""..md_colors[status_colors[status]].."\">"..statuses[status].."</font>"
|
||||
end
|
||||
|
||||
function table_to_tables(tab, num)
|
||||
local out_tab = {}
|
||||
local row = {}
|
||||
|
||||
for k,v in ipairs(tab) do
|
||||
table.insert(row, v)
|
||||
if k % num == 0 then
|
||||
table.insert(out_tab, row)
|
||||
row = {}
|
||||
end
|
||||
end
|
||||
|
||||
return out_tab
|
||||
end
|
||||
@@ -4,6 +4,7 @@
|
||||
-- type = "widget"
|
||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||
-- version = "1.0"
|
||||
-- foldable = "false"
|
||||
|
||||
json = require "json"
|
||||
url = require "url"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
-- type = "widget"
|
||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||
-- version = "1.0"
|
||||
-- foldable = "false"
|
||||
|
||||
function on_resume()
|
||||
local year_days = 365
|
||||
Reference in New Issue
Block a user