Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Creating simple shortcuts for script
-
Hello,
I am beginner and new to the forum.I am struggling to display in a user friendly way text output of a Pythonista script that works and does not require arguments.
Creating à Home Screen shortcut from Pythonista does not work, it opens safari but does not create a shortcuts. Any idea?
Using Shortcuts requires to allow the script to run and then the shortcut automation keeps running until manually closed…
Do you have any suggestions ?
Thank you -
@ysiegel If in the Shortcuts app, you create a shortcut which defines an url like
pythonista3://MyFolder/MyScript?action=run
and a 2nd action
open urlAnd you configure this shortcut on the Home Screen,
When you tap the icon, it will open Pythonista and run your script (asking an authorization only the first time)
Unfortunately, Pythonista stays active because Apple does not allow to close automatically an active app.
But, between us 🙄, if you end your script by "os.abort()", Pythonista will crash and IOS will show the Home Screen.
-
Agreed. If a URL starts with
http://
orhttps://
then it will open in your browser. If a URL starts withpythonista3://
it should open in Pythonista. -
Many thanks for your input, it works!
I have a separate question, the shortcut launch is a bit clumsy (behaviour keeps changing, sometime I have to click to stop execution…)
But I like the geofencing trigger….If I want to launch a script from home screen there is an option in Pythonista to create such shortcuts but it does not create anything… any idea why?
Thanks!
-
@ysiegel said
If I want to launch a script from home screen there is an option in Pythonista to create such shortcuts but it does not create anything… any idea why?
Does not work from an iOS version, I don't know why...
But, anyway, the last part of the process was manual in Safari: tap share button, add on Home Screen, ...
Then using Shortcuts app to configure your Home Screen icon is not so bad -
Ok thank you
-
Hello,
I still haven’t found a way to run and display retrieved information (through Pythonista script) on Lock Screen triggered by geofencing automation without need to unlock screen or tap anywhere…
I just want to show notification with some information based on geofencing trigger without user intervention…
I understand this is more an iOS shortcut question, but does anyone know if it is feasible and how?
Triggering a Pythonista script requires unlocking and tapping and it usually does not fire… whereas it works perfectly if manually launched when phone is unlocked…
Thanks -
iOS gets pretty picky about letting apps run in the background. There are ways that push notifications can work, which allow some background processing when the notification comes in, but IIRC requires a permission. Also, the app has to be completely stopped, and then is restarted in the background to process the notification.
It would have been possible for @omz to create a customizable notification system, kind of like the extensions, where a small script can be programmed to run. But we can't really do this even with objc_util, because once the app is shut down by iOS, any swizzles we make to the app will stop working.
-
Ok many thanks, too bad it is not possible to do it. I wanted to display data based on geofencing (train schedule when I leave home)
-
@ysiegel What you can do in the Shortcuts app is an automation that runs when you leave your home.
This automation can run a shortcut.
This shortcut can end by sending a notification with the text you want.
Sure that all this runs when your locked screen is displayed.
Now, you have to find a way to get your train schedule via shortcuts actions, without Pythonista,
By example by posting a request to an api server and getting the result, what the Shortcut app allows.If your Pythonista script is short, perhaps could you translate it into shortcut actions
For instance, suppose you have a table of schedules and you have to select one in function of current time.