Skip to content

Instantly share code, notes, and snippets.

@hiilppp
Last active July 7, 2019 11:45
Show Gist options
  • Save hiilppp/24475fe4f6dcae3afc6a to your computer and use it in GitHub Desktop.
Save hiilppp/24475fe4f6dcae3afc6a to your computer and use it in GitHub Desktop.
AppleScript to be used as Automator Service that sends Drafts Actions as executable Pushover Notifications to your iOS device. The first line of the received text is expected to be the name of a Drafts Action, the rest will be used as input.
-- Replace "[Pushover_user_key]" on line #22 with your Pushover accout's user
-- key. (You can find it here: <https://pushover.net/dashboard>)
-- You should probably also replace the app token provided on line #21 with one
-- of your own. (They can be generated here: <https://pushover.net/apps/build>)
-- And, finally, replace "xxxxxx" on line #25 with your Drafts URL Key if you
-- use one. (It can be found under Drafts > Settings > URL Security.)
on URL_encode(a)
return do shell script "/usr/bin/python -c \"import sys, urllib; print urllib.quote(sys.argv[1])\" \"" & a & "\""
end URL_encode
on run {input}
set input to input as string
set text item delimiters to ASCII character 10 -- LF
set input_head to text item 1 of input
set input_body to text items 2 through (count text items of input) of input as string
set text item delimiters to ""
set input_parsed to input_head & ": “" & input_body & "”"
do shell script "curl -s -F \"token=aHwz2itBYkNBbEoFPFutqXr1ueFH7f\" \\
-F \"user=[Pushover_user_key]\" \\
-F \"title=Execute in Drafts\" \\
-F \"message=" & input_parsed & "\" \\
-F \"url=drafts://x-callback-url/create?text=" & URL_encode(input_body) & "&action=" & URL_encode(input_head) & "&key=xxxxxx\" \\
-F \"url_title=Execute!\" \\
-F \"sound=none\" \\
https://api.pushover.net/1/messages.json"
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment