Skip to content

Instantly share code, notes, and snippets.

@myles
Created July 8, 2014 17:12
Show Gist options
  • Save myles/da733c02e3ee407c9e97 to your computer and use it in GitHub Desktop.
Save myles/da733c02e3ee407c9e97 to your computer and use it in GitHub Desktop.
import sys
import json
import urllib
import clipboard
import webbrowser
data = urllib.urlopen('http://ifconfig.me/all.json')
ifconfig = json.loads(data.read())
ip_addr = ifconfig.get('ip_addr', '127.0.0.1')
arg = sys.argv
if len(arg) == 2:
if arg[1] == "1":
# Drafts
webbrowser.open("drafts://x-callback-url/create?text=" + urllib.quote(ip_addr))
elif arg[1] == "2":
# iMessage
webbrowser.open("launch://messaging?body=" + urllib.quote(ip_addr))
elif arg[1] == "3":
# Email
webbrowser.open("launch://email?subject=" + urllib.quote("My IP address") + "&body=" + urllib.quote(ip_addr))
else:
webbrowser.open("launch:")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment