Skip to content

Instantly share code, notes, and snippets.

@MikeTheGreat
Last active June 5, 2024 06:15
Show Gist options
  • Save MikeTheGreat/fbc0a0ff6dce5a4a5a569e77d5b18b23 to your computer and use it in GitHub Desktop.
Save MikeTheGreat/fbc0a0ff6dce5a4a5a569e77d5b18b23 to your computer and use it in GitHub Desktop.
Disable sleep on any Mac
# Useful to prevent Macbooks to go to sleep when closing the lid instead of running tools that requires a Kernel Extension (e.g. InsomniaX) and more
#
# References:
# https://www.unix.com/man-page/osx/1/pmset/
# https://www.unix.com/man-page/osx/8/caffeinate/
# To stop sleep for a command: ######################
caffeinate -disu make
# To permanently change sleep settings: ######################
# Before doing anything, save your current configuration using
### REMEMBER hibernatemode VALUE!!!!
pmset -g
# To disable sleep
sudo pmset -a sleep 0; sudo pmset -a hibernatemode 0; sudo pmset -a disablesleep 1; sudo pmset displaysleep 0;
# And to go back to normal
# sudo pmset -a sleep 1; sudo pmset -a hibernatemode [original hibernatemode value]; sudo pmset -a disablesleep 0; sudo pmset displaysleep 1;
sudo pmset -a sleep 1; sudo pmset -a hibernatemode 3; sudo pmset -a disablesleep 0; sudo pmset displaysleep 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment