Drafts Action Directory

Toggle System Sleep

Posted by agiletortoise, Last update 10 months ago

Toggle status of system sleep timer. Disabling the timer will prevent the screen from dimming and device going to sleep while using Drafts.

Install

Steps

  • script

    let isDisabled = app.isIdleDisabled;
    
    let p = Prompt.create();
    p.title = "Toggle Sleep Timeout";
    
    if (isDisabled) {
    	p.message = "Current status: Sleep Disabled\n\nSystem will not dim screen while in Drafts.";
    }
    else {
    	p.message = "Current status: Sleep Enabled\n\nSystem will automatically dim screen and sleep to preserve battery while in Drafts.";
    }
    
    p.addButton("Disable Sleep");
    p.addButton("Enable Sleep");
    
    if (p.show()) {
    	if (p.buttonPressed == "Disable Sleep") {
    		app.setIdleDisabled(true);
    	}
    	else {
    		app.setIdleDisabled(false);
    	}
    }

Options

  • After Success Nothing
    Notification Error
    Log Level None

Comments

Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.