Shortcuts-app automation to prevent iPhone screen from going to sleep

The closest you can currently do is to automatically open the correct settings screen using Shortcuts. This can be achieved by creating an URL and opening it in Safari:

prefs:root=DISPLAY&path=AUTOLOCK

This will open the settings accordingly in the right place.

Action Setting

More URL schemes can be found here: A Comprehensive Guide to All 120+ Settings URLs Supported by iOS and iPadOS 13.1.


As a workaround, I'd use combination of Low-power mode and Auto-Lock after t time.

In Display and Brightness Settings, you can set auto-lock to 1-5 minutes or never. Now since this might drain battery, use low power mode when your "condition is not met". This locks the auto-lock timer to 30 seconds.

Low power mode has its own cons, like some syncs disabled, reduced brightness etc.