Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ahostmadsen

macrumors 65816
Original poster
Dec 28, 2009
1,121
867
In MacOS 12, there was an option: 'do not go to sleep when on power adapter' under the energy setting (I'm not sure about the exact wording). I cannot find that in Ventura. How do I prevent the computer from going to sleep? To be clear, I want the screen to go off, but the computer to continue to run.
 
In MacOS 12, there was an option: 'do not go to sleep when on power adapter' under the energy setting (I'm not sure about the exact wording). I cannot find that in Ventura. How do I prevent the computer from going to sleep? To be clear, I want the screen to go off, but the computer to continue to run.
Sorry, I found it under advanced display settings. But not logical.
 
Stop. Turn everything back to how it was before.

Run caffeinate in the terminal. Attach -d if you want the display to stay on. To stop it, hit Ctrl + C. Simple as that.
Useful. My issue is that when a Python program is running, it doesn't prevent the computer from going to sleep. Perhaps I can issue this command from inside Python to prevent the computer sleeping while the Python program is running, and then allow sleep again when the Python program is finished.
 
Vice versa, you can run python within caffeinate as in caffeinate python script.py, or possibly just caffeinate script.py if script.py is executable.

Then the computer will be prevented from sleeping by caffeinate until the process run be caffeinate terminates. You can also attach caffeinate to an already running process. You should look at the man page.
 
  • Like
Reactions: ahostmadsen
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.