Skip to content

Instantly share code, notes, and snippets.

@sudmed
Last active February 16, 2023 18:06
Show Gist options
  • Save sudmed/2b32837ac61542b8c893abc237081a4a to your computer and use it in GitHub Desktop.
Save sudmed/2b32837ac61542b8c893abc237081a4a to your computer and use it in GitHub Desktop.
Disable & Enable Sleeping when the lid of Mac is closed

Disable Sleeping when the lid is closed

sudo pmset -a sleep 0; sudo pmset -a disablesleep 1

Re-enable sleeping when the lid is closed (running on battery only)

sudo pmset -b sleep 5; sudo pmset -b disablesleep 0

pmset sleep - system sleep timer (value in minutes, or 0 to disable)
pmset disablesleep 1 - permanently disable sleep
The -a, -b, -c, -u flags determine whether the settings apply to battery ( -b ), charger (wall power) ( -c ), UPS ( -u ) or all ( -a ).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment