Can’t Sleep, Won’t Sleep

How to keep your Mac awake during important tasks

Photo by Alexander Possingham on Unsplash

Is there anything worse than that awkward moment when your computer goes to sleep in the middle of a presentation?

Well, yes. There are probably a lot of things more awkward than that. Unfortunately, there may not be easy solutions for those situations.

If the above issue does not resonate with you, have you ever had your computer fall asleep while watching a YouTube video? Downloading a file? How about looking at a recipe and the display turns black right after you diced some jalapeño peppers and your hands are covered in fire juice?

In my case, I’m a budding data scientist. I mistakenly left my computer to fit a model I knew would take a while. Every time I came back to check on it, it was still running. It ended up taking 400 minutes! (Subsequent runs would show it should actually take about 105 minutes.)

But no more! There are multiple different ways to customize and prevent a computer from falling asleep at an inopportune time.

Photo by Lucrezia Carnelos on Unsplash


If it keeps us awake, maybe it will work for our computers too?

Please do not dump coffee on your laptop or try to get your hands on a controlled substance. Instead, you can head to the App Store and download one of the following:


What makes this app first? It’s free! It has many different features, but is also very user-friendly. There are boat-loads of customizable preferences and navigating through them is quick and easy.

This app collects only diagnostic data, not data linked to your identity.

I may be a little biased because this is the one I use.

Get Amphetamine here. (The app!) 😳


If you are looking up Amphetamine, you are going to come across this app as well. The two are very similar in that there are many different customizable features.

Developed based on the original app Caffeine, Caffeinated is convenient and easy to use. The developer does not collect any data from this app and currently this app will cost you a few bucks.

Get Caffeinated here


This is another highly-rated app to prevent computers from sleeping while tasks are still running.

Also based on the original Caffeine app but with Amphetamine in mind, this attempts to split the two. It is a more modern, updated take on the original, but pares down some of the features that would not be useful to most.

Currently, it costs a few greenbacks.

Get Lungo here


This app has been around for about the same amount of time as the others and has similar features. What may set this app apart is that it is available in 24 different languages.

As of today, Theine will run you a couple of clams.

Get Theine here

All of the above apps are menu bar icon apps that are compatible with Dark Mode and Retina displays.

“But what if I don’t want an app?” You still have options!

You can try the open-source (generic?) Amphetamine alternative KeepingYouAwake. It does the same thing (prevents your computer from sleeping) without all the extra bells and whistles.

If you have always struggled with spelling the word “caffeinate” then this may be the solution to two problems in one!

Caffeniate is installed and runs through the command line or in a jupyter notebook.

pip install caffeinate

From there, the prompts below can be used to customize or close Caffeinate.

caffeinate -d 
  • opens and runs Caffeinate
caffeinate -i 
  • cancels idle sleeping
caffeinate -s 
  • keeps the computer awake while it’s plugged in
caffeinate -t 1800 (or any number) 
  • leaves your Mac is awake for the number of seconds specified
control + c
  • closes the caffeinate program

Lastly, there is always the option to change your computer’s settings. There may not be as many features as the apps, but depending on your particular issue, you may only need to adjust a few settings.

You can start in System Preferences. Head to “Battery” if you are on a laptop or “Energy Saver” if you are on a desktop. For more details, I’ll let Apple take it from here.

All this talk about sleeping! It might be time for a power nap!

To see the model that took 105 minutes to fit, as well as other projects, please head over to my GitHub profile.

Aspiring Data Scientist, dog lover and running enthusiast

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store