By default if you haven’t used your Mac for a while the computer will go to sleep, however if you are watching a long video or referencing a document you might want it to stay awake indefinitely. There are a few options to achieve this, read on to find out.
Disable sleep in the System Preferences
If you never want your Mac to go to sleep ever, the most straightforward method is simply to disable sleep in the System Preferences. Navigate to the “Energy Saver” section and drag the slider to “Never” under both the Battery & Power Adapter sections. Don’t mind the warning about the display’s life being shortened — it’s not a realistic concern for modern LCD/LED displays which Macs use. The worst that will happen is your Mac’s battery will run flat and it will be forced to go to sleep automatically.
Install the Caffeine app
So how about if you only want your Mac to stay awake sometimes? Like if you’re downloading a big file? The best solution to this is to download the Caffeine app (here), a free piece of software which puts a coffee cup symbol in your menu bar. Clicking the coffee cup toggles whether or not your Mac will be able to go to sleep — full means it won’t sleep and empty means it will. Very simple.
Get the Insomnia app
Now what if you want your Mac to sleep when you close the lid, but not when it’s just sitting open and idle? Or the other way around? Well there’s another app called Insomnia (download here) which gives you a bit more flexibility than Caffeine insofar as it allows you to separately toggle idle sleep (your Mac going to sleep after a certain amount of time when the lid is left open) and lid-closed sleep (your Mac going to sleep when the lid is closed). You can also set either type of sleep to only be disabled for a certain period of time, after which it will automatically be re-enabled, in case you forget.
Temporarily disable sleep via the Terminal
If you want to temporarily disable sleep on your Mac but for some reason or another can’t/don’t want to install a third party app, another option is to use the built-in Terminal utility. Simply open up the Terminal utility/app and type the following command followed by the enter key:
The terminal window will then show something like the below, which indicates sleep is disabled on your Mac:
To re-enable sleep simply press the CONTROL-C key combo in the Terminal window to stop the command, or else it will disable when you close the terminal window or restart your Mac.