Skip to content

Instantly share code, notes, and snippets.

@alessaba
Last active December 20, 2015 22:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alessaba/6204739 to your computer and use it in GitHub Desktop.
Save alessaba/6204739 to your computer and use it in GitHub Desktop.
prowl_sender
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#Sender (for Mac OS X)
# For details, in Mac OS X Terminal type: man pbcopy
import subprocess, sys
import prowlpy
def getClipboardData(): # Only works for data types: {txt | rtf | ps}
p = subprocess.Popen(['pbpaste'], stdout=subprocess.PIPE)
retcode = p.wait()
data = p.stdout.read()
return data
def setClipboardData(data):
p = subprocess.Popen(['pbcopy'], stdin=subprocess.PIPE)
p.stdin.write(data)
p.stdin.close()
retcode = p.wait()
def sendTextToiOS(clip):
inText=clip.replace(' ','[space]') #the [space] is considered by the reciever as a space
apikey = 'g8fbc8a3b767ee225uc3a088bc04ecbc0ac93160' #Change it with your own token
url="pythonista://prowlista?action=run&args="+inText
p = prowlpy.Prowl(apikey)
try:
p.add('Prowlista','Clipboard here:',clip, 1, None,url)
except Exception,msg:
print msg
def main(argv):
clip= getClipboardData()
if not clip:
print('No text found on the Mac OS X Pasteboard.')
return -1 # signal error
print('Got: ' + clip)
sendTextToiOS(clip)
return 0 # noError
if __name__ == '__main__':
sys.exit(main(sys.argv))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment