Skip to content

Instantly share code, notes, and snippets.

@tdhopper
Last active September 13, 2024 15:05
Show Gist options
  • Save tdhopper/f70bea7446ec03a1df98 to your computer and use it in GitHub Desktop.
Save tdhopper/f70bea7446ec03a1df98 to your computer and use it in GitHub Desktop.
Using Keyboard Maestro to paste text from your clipboard to Drafts on iOS via Pushover. The Keyboard Maestro action will send a link to Pushover that will open the text in Drafts. The amount of text you can send is limited by the Pushover API.
rawurlencode() {
local string="${1}"
local strlen=${#string}
local encoded=""
for (( pos=0 ; pos<strlen ; pos++ )); do
c=${string:$pos:1}
case "$c" in
[-_.~a-zA-Z0-9] ) o="${c}" ;;
* ) printf -v o '%%%02x' "'$c"
esac
encoded+="${o}"
done
REPLY="${encoded}"
}
clip=$(pbpaste)
rawurlencode "$clip"
curl -s \
-F "token=YOUR_TOKEN" \
-F "user=YOUR_PUSHOVER_USER" \
-F "message=New text from your Mac" \
-F "url=drafts://x-callback-url/create?text=$REPLY" \
-F "device=iphone" \
https://api.pushover.net/1/messages.json
@tdhopper
Copy link
Author

tdhopper commented Jun 4, 2014

In Pushover:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment