Add Tasker command search and edit sunrise widget #16
@@ -1,36 +0,0 @@
|
||||
-- name = "Public IP"
|
||||
-- description = "Shows your public IP in the search bar"
|
||||
-- data_source = "ipify.org"
|
||||
-- type = "search"
|
||||
-- author = "Sriram SV"
|
||||
-- version = "1.0"
|
||||
|
||||
local md_color = require "md_colors"
|
||||
local blue = md_colors.blue_500
|
||||
local red = md_colors.red_500
|
||||
|
||||
local ip = ""
|
||||
function on_search(input)
|
||||
if input:lower():find("^ip$") then
|
||||
get_ip()
|
||||
end
|
||||
end
|
||||
|
||||
function on_click()
|
||||
system:copy_to_clipboard(ip)
|
||||
end
|
||||
|
||||
function get_ip()
|
||||
http:get("https://api.ipify.org")
|
||||
end
|
||||
|
||||
function on_network_result(result,code)
|
||||
if code >= 200 and code < 300 then
|
||||
ip = result
|
||||
search:show({result},{blue})
|
||||
else
|
||||
search:show({"Server Error"},{red})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -8,12 +8,42 @@
|
||||
|
||||
local json = require "json"
|
||||
local date = require "date"
|
||||
function on_alarm()
|
||||
local location=system:location()
|
||||
url="https://api.sunrise-sunset.org/json?lat="..location[1].."&lng="..location[2].."&date=today&formatted=1"
|
||||
http:get(url)
|
||||
|
||||
l1 = {}
|
||||
l2 = {}
|
||||
function on_resume()
|
||||
l2=settings:get_kv()
|
||||
if next(l2) == nil then
|
||||
ui:show_text("Tap to request location")
|
||||
else
|
||||
get_sunrise_sunset(l2)
|
||||
end
|
||||
end
|
||||
|
||||
function on_click()
|
||||
system:request_location()
|
||||
ui:show_text("Loading...")
|
||||
end
|
||||
|
||||
function on_location_result(location)
|
||||
if location ~= nil then
|
||||
l1.lat = location[1]
|
||||
l1.long = location[2]
|
||||
settings:set_kv(l1)
|
||||
get_sunrise_sunset(l1)
|
||||
else
|
||||
ui:show_text("Error")
|
||||
end
|
||||
end
|
||||
|
||||
function get_sunrise_sunset(location)
|
||||
if location~=nil then
|
||||
url="https://api.sunrise-sunset.org/json?lat="..location.lat.."&lng="..location.long.."&date=today&formatted=1"
|
||||
http:get(url)
|
||||
else
|
||||
ui:show_text("Location Empty")
|
||||
end
|
||||
end
|
||||
|
||||
function on_network_result(result)
|
||||
local t = json.decode(result)
|
||||
|
||||
24
community/tasker-command-search.lua
Normal file
24
community/tasker-command-search.lua
Normal file
@@ -0,0 +1,24 @@
|
||||
-- name = "Tasker Command Search"
|
||||
-- description = "Sends tasker command from search bar"
|
||||
-- data_source = "tasker"
|
||||
-- type = "search"
|
||||
-- author = "Sriram SV"
|
||||
-- version = "1.0"
|
||||
-- prefix = "tasker | Tasker | command"
|
||||
|
||||
local md_color = require "md_colors"
|
||||
local orange = md_colors.orange_500
|
||||
|
||||
text_from = ""
|
||||
text_to = ""
|
||||
|
||||
function on_search(input)
|
||||
text_from = input
|
||||
text_to = ""
|
||||
search:show({input},{orange})
|
||||
end
|
||||
|
||||
function on_click(idx)
|
||||
text_from=text_from:replace(" ", "=:=")
|
||||
tasker:send_command(text_from)
|
||||
end
|
||||
Reference in New Issue
Block a user