Prevent sleep

Hi all,

Does anyone know of a way to prevent the computer from going into sleep mode, or alternatively, allowing a script to run before sleep?

Thanks,

S.

Hi Stads,

take a look at Kai’s article AppleScript Tutorial on Scripting System Preferences especially the part Accessing Energy Saver Settings.

Note: the value 0 of a pmset parameter is the equivalent to “never”

Great Stefan!

I had looked into pmset already but missed the 0=never…

Edit: It almost works for what I needed: I was hoping to also prevent a MacBook(pro) to go to sleep when the lid is closed. I know that ‘pmset lidwake 0’ does the opposite; preventing coming out of sleep when opening the lid…