Quickly Create Pythonista Shortcuts with Custom Icons

Interesting set of scripts posted on the Pythonista Community Forums (which, by the way, are becoming a daily appointment for me as Pythonista users are coming up with all sorts of tricks). Using Pythonista as a web server and Safari, you can create local (and unsigned) .mobileconfig files to automate the installation of Pythonista webclip icons. As I explained in my review, Pythonista can launch specific scripts using webclips created from a special webpage:

Upon tapping, a Pythonista Home screen bookmark will briefly open a blank page and then immediately redirect to the script you’ve configured in the Pythonista app. I’m fairly certain there’s no way to avoid showing a blank page for a second before redirecting to Pythonista; fortunately, it’s really just the fraction of a second, as the redirecting process is instantaneous both on my iPad 3 and iPhone 5.

Using the scripts linked in the forums, I easily managed to create a custom icon for my Markdown-Poster workflow that uses Poster’s icon instead of the default Pythonista one. To extract and convert iOS icons for personal use, I recommend Crunch, which I’ve also previously reviewed. I was intrigued by how forum user pudquick figured out the installation of provisioning profiles from Pythonista:

When you run the code, it starts a web server in Pythonista - and copies the URL for the generated .mobileconfig file to the clipboard. When you switch to Safari and attempt to load the URL, the socket connects - but it’s waiting for communication from the web server in Pythonista (which is paused, since it’s in the background).

As soon as you switch back to Pythonista, this un-pauses the web server fast enough to cause Safari to finish loading the .mobileconfig file while it’s swapping to the background, which then triggers the installation screen!

Combining the script with this other one to easily generate base64 images, I suggest replacing Image.BILINEAR on line 20 with Image.ANTIALIAS for slower but better results in the overall crispness of the icon (I also changed the size to 114x114 for my Retina iPad).

Looking forward to improvements for Pythonista shortcuts (as mentioned by developer Ole Zorn in the thread), this is a nice stopgap solution to use scripts with custom shortcut icons in the Home screen.