Skip to main content Keep a Mac awake for any duration with a user friendly easy to setup script that just works.. : r/mac
r/mac icon
Go to mac

Keep a Mac awake for any duration with a user friendly easy to setup script that just works..

News/Article

Update 3 Jul 23: Thanks everyone for your support through the V0.1 MVP. The app has now been updated to V0.2 and is now easy to deploy, interactive and includes more functionality. There's more to come as well. Enjoy and keep it real 💪


Hey all,

I often need to prevent a Mac from sleeping and Caffeinate and similar tools are downloaded programs that didn't work well for me, especially in enterprise settings, so I created this user friendly script based interactive app that should provide more advanced macOS sleep options than what are offered in the OS UI.

You can keep your Mac awake indefinitely, for any duration or toggle sleep, all while turning off your display, locking your Mac or closing your MacBook lid. Can't be easier than that..

This software runs on the latest macOS and uses the built in commands so it doesn't require any extra software or libraries. This app is literally a few kb in size.

The app allows you to specify a wake duration in seconds, minutes, or hours, including combined arguments (e.g. by running ./terminawake.sh 1h 30m 15s).

But you can click the shortcut that the setup creates or just run ./terminawake.sh and enter the interactive Terminal.

You do not need any programming knowledge to use this app.

Check out our open-source and free to distribute (MIT) repository at - https://github.com/Post2Fix/macos-stay-awake

There are extremely simple instructions how to setup and run the whole thing.

Next we'll try to turn it into an executable MacOS app for everyone but until then hopefully some early adopters will find this useful, especially in enterprize settings. Let me know if you have any suggestions or issues.

Best.

Talk with Meta AI, you can get a deeper understanding of complex topics in a new way.
Clickable image which will reveal the video player: Talk with Meta AI, you can get a deeper understanding of complex topics in a new way.
Sort by:
Best
Open comment sort options
[deleted]

Amphetamine does the job pretty well and it's free.

Thanks but afaik, neither Amphetamine or Caffeinate are open source. These are also large programs VS this tiny script that uses the native MacOS 'sudo pmset disablesleep 1/0' commands that anyone can run without installing anything.

Also, it's not like I didn't try those. They just didn't do it the way I think it should be. Hopefully you check it out, it's pretty good.

More replies
More replies

I’m sorry, but I need my stay awake applications to be named after drugs. It’s the only way I know it will be effective.

Very good point, you're right! I'm being way too vanilla.

So let's discuss drug names! 😂

You know that Amphetamine almost got kicked out of the App Store because of its name.. Maybe something a little more legal?

I'll gladly change the name though. What's a known legal booster that you can dose to sustain for a specific duration and pull out any time to hit the sack? Sounds like stuff for astronauts..

More replies

You should work in marketing for sure 😎 I'm not even kidding..

More replies
More replies

Caffeinate is already available on macOS' command line.

CAFFEINATE(8) System Manager's Manual CAFFEINATE(8)
NAME
caffeinate – prevent the system from sleeping on behalf of a utility
SYNOPSIS
caffeinate [-disu] [-t timeout] [-w pid] [utility arguments...]
DESCRIPTION
caffeinate creates assertions to alter system sleep behavior. If no assertion flags are specified, caffeinate creates an assertion
to prevent idle sleep. If a utility is specified, caffeinate creates the assertions on the utility's behalf, and those assertions
will persist for the duration of the utility's execution. Otherwise, caffeinate creates the assertions directly, and those
assertions will persist until caffeinate exits.
Available options:
-d Create an assertion to prevent the display from sleeping.
-i Create an assertion to prevent the system from idle sleeping.
-m Create an assertion to prevent the disk from idle sleeping.
-s Create an assertion to prevent the system from sleeping. This assertion is valid only when system is running on AC power.
-u Create an assertion to declare that user is active. If the display is off, this option turns the display on and prevents the
display from going into idle sleep. If a timeout is not specified with '-t' option, then this assertion is taken with a
default of 5 second timeout.
-t Specifies the timeout value in seconds for which this assertion has to be valid. The assertion is dropped after the
specified timeout. Timeout value is not used when an utility is invoked with this command.
-w Waits for the process with the specified pid to exit. Once the the process exits, the assertion is also released. This
option is ignored when used with utility option.
EXAMPLE
caffeinate -i make
caffeinate forks a process, execs "make" in it, and holds an assertion that prevents idle sleep as long as that process is
running.
SEE ALSO
pmset(1)

Edited

After developing V0.2 I can say that pmset is better than Caffienate.

The goal of this program, until it has a UI, is to be as user friendly as possible by guiding users, in plain english, to easily manage advance sleep settings that the MacOS UI doesn't present.

More replies
More replies
Profile Badge for the Achievement Top 1% Commenter Top 1% Commenter

Have you looked at /usr/bin/caffeinate?

Edited

From what I see, Caffeinate uses pmset to do things that this program uses pmset to do directly, like creating a defined duration sleep delay using input during the launch of the program. Also using control-c to end the script isn't as intuitive as using a guiding program.

More replies
More replies