Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable/Cancel Sleep Command on MacOSX

It seems to be impossible to completely disable the Sleep option in MacOSX so that a user cannot manually put the system to sleep.

Is there a way in Leopard (or even Snow Leopard) for AppleScript to catch the Sleep event and cancel it?

like image 897
Ryan R. Rosario Avatar asked Feb 28 '23 11:02

Ryan R. Rosario


2 Answers

The answer to your problem is however a simple Apple-osx-Terminal command that prevents OSX to go idle:


$ pmset noidle
Preventing idle sleep (^C to exit)...

The only way to reset the no-sleeping is to issue a 'Control-C'.
See the man pages of pmset for more details.

This command has been deprecated in favor for


$ caffeinate -i

Which does roughly the same. You can also run caffeinate for a pre-determined amount of time to prevent sleeping, say for 4 hours while you download something, and then run it in the background by adding & to it:


$ caffeinate -t 144000 &

like image 196
Harm Avatar answered Mar 12 '23 03:03

Harm


You can't do this from user mode, because the power manager prevents it, so you'll need to use a kernel extension, such as InsomniaX.

like image 36
Nicholas Riley Avatar answered Mar 12 '23 01:03

Nicholas Riley