Pythonista integration with Shortcuts
-
I would like to ask a question. will there be closer integration of Pythonista with Shortcuts. I would like more features.For example, execute the specified script in Pythonista without pausing and returning to Shortcuts
-
@ihf shortcuts supports x-callback-urls
https://support.apple.com/guide/shortcuts/use-x-callback-url-apdcd7f20a6f/iosSo, you should be able to call shortcuts from pythonista, and then have shortcuts reopen pythonista after
-
@jonb I actually knew I could get back, I was wondering if there was a way for the Shortcuts app not to have to open on the screen, the way it seems to work when Siri executes one.
-
Now that there is a Shortcuts module in the Pythonista beta, is there a way to run a shortcut from Pythonista and have it executed without seeing the Shortcuts app open on the screen?
I don't think that's possible at all. (In case you're wondering: Yes, there's obviously a private framework that does this, but I'm almost certain it would require special, Apple-only entitlements for the app.)
-
@ihf I think it is the same for Shortcut as for Pythonista: a background run of a small non-UI script is only possible in Siri. In all other cases the full app is launched in foreground.
-
you can call pythonista from shortcuts and get a reply from pythonista,
here is a client pythonista app, put in the home folder in the "on the iphone" section
#!/usr/bin/env python # sys.args[0]=workflow.py import sys,json,urllib from datetime import datetime import console,webbrowser,clipboard def main(): console.clear() console.set_font('Menlo',12) console.set_color(1,1,1) #print json.dumps(sys.argv, indent=4) dtf = '%Y-%m-%d %H:%M:%S' output = dict( when=datetime.now().strftime(dtf), args=sys.argv ) result = json.dumps(output,indent=4) print(result) x_callback=sys.argv[-1] if not '://' in x_callback: return url = x_callback + '?argv=' + urllib.quote(result) webbrowser.open(url) if __name__ == '__main__': main()
here is the workflow,
x-callback-url = "pythonista://workflow.py?action=run&argv=1&argv=2"
note the change to the x-success parameter
"success key"=args
-
@cvp Well, not quite. You can also launch these shortcuts using Spotlight search, and the Shortcuts Today widget, in case you don't want to use Siri.
-
@omz For à very little shortcut script without any UI, if you launch it via Share, it runs without starting the full app, but if via Widget, it starts the full app.
-
@cvp Not necessarily, if I remember correctly. I was able to run a script that writes a value to a file, and it did seem to run in the background when launched from the Widget. It's possible that this behavior changed in some iOS update, but I'll check.
-
@omz Perhaps, my post was not clear, I speak about a "script" of the Shortcut app, not a Pythonista script. It only does:
Text "test"
Copy to Clipboard