Refactor push_tasks and add send_push,timetask functions

This commit is contained in:
mitchell 2020-08-15 19:06:43 -04:00
parent 5e8e764238
commit 2f5438dc21
3 changed files with 22 additions and 8 deletions

View File

@ -1,10 +1,4 @@
function push_tasks -a token user -d 'Push tasks as a notification to your phone' function push_tasks -d 'Push tasks as a notification to your phone'
set tasks (task +READY export | jq 'sort_by(.urgency) | reverse | map(@text "\(.description)\nLink: \(.link)") | join("\n\n")') set tasks (task +READY export | jq 'sort_by(.urgency) | reverse | map(@text "\(.description)\nLink: \(.link)") | join("\n\n")')
set payload "{\"token\":\"$token\",\"user\":\"$user\",\"title\":\"Tasks\",\"message\":$tasks}" send_push $tasks
curl \
-X POST \
-H 'Content-Type: application/json' \
-d $payload \
https://api.pushover.net/1/messages.json
end end

View File

@ -0,0 +1,11 @@
function send_push -a message -d 'Send a push notification to your phone via pushover (optional delay as second arg)'
if test -n "$argv[2]"; sleep $argv[2]; end
set payload "{\"token\":\"$pushover_token\",\"user\":\"$pushover_user\",\"title\":\"Tasks\",\"message\":$message}"
curl \
-X POST \
-H 'Content-Type: application/json' \
-d $payload \
https://api.pushover.net/1/messages.json
end

View File

@ -0,0 +1,9 @@
function tasktime -a id time -d 'Set a time to check-in on task progress using pushover'
set half_time (math $time/2)
set desc (task _get $id.description)
task $id start
fish -c "send_push '\"Half-time: $desc\"' $half_time" > /dev/null & disown
fish -c "send_push '\"Timer over: $desc\"' $time" > /dev/null & disown
end