Poor (or rich?) person’s Launch Center Pro for iPad
I’m calling this a poor person’s workflow, because the solution I’m going to propose is a bit “hack-y”, but it’s for rich people who can afford $5 for Pythonista instead of Launch Center’s $2.
Ever since I wrote my first Python script, the Daily Diary one, and after I saw that you can put direct “links” to scripts on the springboard, it dawned on me that Pythonista could be used as Launch Center equivalent.
Note that for the following workflow Launch Center Pro (shortened to LCP) is not required, although it would make some things easier for you.
Let’s start with talking about URL schemes first. As a power feature many iOS applications support a custom URL scheme. It’s become a very prominent feature in many apps.
LCP is basically a composer for these URLs. Its best feature: displaying a prompt to the user to pass on input on execution. This way it becomes possible to create OmniFocus tasks right from Launch Center Pro or search on DuckDuckGo and many other things. The feature is pretty amazing, but with the power of Pythonista your possibilities become endless. With the app you cannot only display prompts, you can also pull data from the web and do calculations on them. The only problem is that Pyhonista is harder to use than it is to use Launch Center Pro. So by using Pyhonista you gain the possibilities of what an entire computer has to offer, at the cost of usability. You’re not limited anymore by what LCP has to offer, you can build your own stuff. I’m showing how to search DuckDuckGo in Google Chrome below. To my knowledge this is not built into LCP.
We’re going to use Launch Center Pro and Day One as example here. First we need to find our URL. The easiest you can do is open Launch Center Pro and add a new action for the app you want to have a shortcut for. Then when you’re done, go back to editing the action and copy the URL to the clipboard. If you don’t have LCP head over to handleOpenURL and search for your app. Unfortunately Day One is not in their database.
LCP’s “New Entry with Text” with a prompt produces the following URL:
Let’s dissect it first:
dayone://: the URL that calls Day One. It’s basically the replacement for
https://which is reserved for Safari.
post: a keyword for Day One where the URL goes to.
?entry=: The first argument (arguments starts after the
entryfollowed by an equal sign which tells Day One the contents of the new entry. Every new argument starts with a
&. You see how to use this in the OmniFocus script below.
- Every time there is a
[prompt], we need to make an input variable in the Pythonista script.
Basic Python script
import webbrowser import urllib dayone_url = "dayone://post?entry=" # input prompt = "> " entry_text = raw_input("User input: \n" + prompt) # url encode entry_text = urllib.quote(entry_text) # open in day one webbrowser.open(dayone_url + entry_text)
Adapting to your needs
When ever you see a
[prompt] in one of Launch Center’s actions, you need these two lines:
entry_text = raw_input("User input: \n") entry_text = urllib.quote(entry_text)
Give every entry a unique name and use
+ to concatenate strings together.
urllib.quote encodes the input into URL form, e.g. spaces are replaced with
Getting shortcut icons on your home screen
Now that you have the basic ingredients on how to “convert” LCP actions into a Python script, let’s see how to call these quickly. The method is simple, omz:software has a special page where you can create web clips for Pythonista scripts.
Follow the instructions and make sure to write
action=run into the “arguments” field. Then tap “Create Shortcut”. The page reloads. Now add a new bookmark to you home screen. (Action menu)
That’s it, basically, you can call your “Launch Center Pro” action now by tapping its icon on the home screen.
Bonus: Add OmniFocus task as Pythonista shortcut
Launch Center Pro URL:
import webbrowser import urllib # omnifocus:///add?name=[prompt]¬e=[prompt] omnifocus_url = "omnifocus:///add?" task_name_url = "name=" note_url = "note=" # input prompt = "> " task = raw_input("Task: \n" + prompt) note = raw_input("Note: \n" + prompt) # url encode task = urllib.quote(task) note = urllib.quote(note) # open in omnifocus webbrowser.open(omnifocus_url + task_name_url + task + "&" + note_url + note)
Bonus 2: Search DuckDuckGo in Google Chrome for iOS
Google Chrome URL scheme:
Pythonista script (I’ve stripped out comments to make it shorter):
import webbrowser import urllib # http://duckduckgo.com/?q=asdf ddg_url = "googlechromes://duckduckgo.com/?" query_url = "q=" # input prompt = "> " query = raw_input("Query: \n" + prompt) query = urllib.quote(query) # open in chrome webbrowser.open(ddg_url + query_url + query)
With a little knowledge of HTML you can even give these web clips custom icons, but this goes to far for this posting…