I have a script that I want to run frequently. I want to know if it is possible that Siri could run the script in background frequently( say every 2 hours) ? The script basically checks the battery level and will notify if battery is below 30%.
iOS 14 will bring automation that can be run when battery level is at or below a percentage
I don’t want an automation. I want to know whether a script can run in background or not.
And how to run it, if possible?
Time based triggers and scripts fall under the remit of automation, so I think it actually is an automation you want based on the question you started with; and this is the Automators forum after all
If your script is viable as an inline script (a type of Shortcuts action for Scriptable scripts), that should be possible to run in the background by a shortcut containing it running in the background. The issue is where Shortcuts has to switch out to another app to complete the action.
But do note that @dustinknopoff has a great point in that you could utilise Shortcuts without a script on iOS14. If all you wish to do is pop up a notification, the chances are Shortcuts is a simpler, quicker, and overall better way to do it. But, if your Scriptable script is doing more than just that, then that could be where it becomes a better option to use a combination of the two. In order to tell we need to get the full picture.
I realise you boosted about a battery reminder notification in Scriptable the other day, so the question presumably relates to what you have since done with that script?
Also if you need a pre-iOS14 option, then you would need to investigate some of the constantly running shortcut cotrol shortcuts, but I think they in turn will affect battery life and general usability and are likely not the most viable option.
I think I should wait for iOS 14 then as it might present better options.
Thanks @sylumer and @dustinknopoff.
Just one more small question? From scriptable, can we create and edit automations in shortcuts app?
No. Shortcuts doesn’t expose any framework to allow that and Shortcuts themselves aren’t loaded from file in the same sort of way Scriptable’s scripts are. The closest that I think you could come is building the plist file structure of a Shortcut from Scriptable and maybe triggering an option to import from file; but again that’s something coming (back) in iOS14,
There is literally an automation in the Shortcuts app that will run whatever actions you want once the battery hits the percentage you specify it to hit. And you don’t have to “allow” it to run (just turn off the toggle). This is coming in iOS 14
I think that’s what @dustinknopoff was referring to in the first reply.
I found the original reply to the OP post was very helpful