Caffeinate FileMaker Pro

Did you know that FileMaker Pro or the whole computer can go to sleep while doing a longer script?

On macOS there is a feature called App Nap to save energy by sleeping applications. And of course on Windows and macOS the display gets to sleep after some time and sometimes even the whole PC or Mac goes to sleep.

With MBS FileMaker Plugin, you can add a script line on the start of your script and then a second line on the end of the script.

The start of the script calls the ProcessActivity.beginActivity function like this:

Set Variable [ $activity ; Value: MBS( "ProcessActivity.beginActivity"; "IdleSystemSleepDisabled UserInitiated"; "Doing Backup in FileMaker" ) ]

On the end of the script, you have a line to end the activity:

Set Variable [ $r ; Value: MBS( "ProcessActivity.endActivity"; $activity ) ]

All activities are cleared when you exit the application.

For complicated scripts with multiple "Exit Script" steps, it may be easier to have a wrapper script like this:

# DoBackup script
 
# Start activity
Set Variable [ $activity ; Value: MBS( "ProcessActivity.beginActivity"; "IdleSystemSleepDisabled UserInitiated"; "Doing Backup in FileMaker" ) ] 
# call the backup script
Perform Script [ Specified: From list ; “DoBackup Internal” ; Parameter: Get(ScriptParameter) ]
# Stop activity
Set Variable [ $r ; Value: MBS( "ProcessActivity.endActivity"; $activity ) ] 
# pass on the script result
Exit Script [ Text Result: Get(ScriptResult) ] 

Windows support was added in v13.0 (with fix in 13.3), so it may prevent display or system sleep there, too.

Let us know if you have questions about this.

3 Likes

This is so good, since I have a dedicated client running time consuming tasks during the night. So I will include this to be on the safe side for the future :+1:

Good to know and great you addressed it! THNX
Shouldn't this be in the host app itself?

Well, if Claris would add all the features, I wouldn't have something to put into my plugin...

4 Likes