Prevent macOS from Sleeping
-
Install Alfred.
-
Ensure
caffeinate
is in your$PATH
, by running:$ which caffeinate /usr/bin/caffeinate
-
Import the Alfred alfred-caffeinate workflow by double-clicking the workflow file after downloading it.
-
The default caffeination time is 1 hour (3600 seconds), but feel free to change this in in
alfred-caffeinate.sh
at line 4.# default caffeination time in seconds default_caffeination=3600
In Alfred type the following:
To caffeinate (default time of 1 hour):
caffeine
To caffeinate 8 hours:
caffeine 8
To resume normal sleep behavior:
caffeine off
Many thanks to the stack overflow community for lots of shell scripting help!