fig. 01 — an 8h session, and the commands underneath
which one, when
awake session
lid open
awake until the timer ends. closing the lid sleeps it.
caffeinate
stay awake, lid closed
lid shut
never sleeps, even shut. screen still sleeps and locks after inactivity.
disablesleep
both
lid might close
awake until you turn it off. closing the lid changes nothing.
caffeinate + disablesleep
idlescreen onscreen off, Mac on
fig. 02, when to use which
# the two commands you keep typing: $ caffeinate -disu $ sudo pmset -a disablesleep 1 # …are now one click. lid open or shut.
the lid setting needs root. the first password prompt installs one sudoers
rule covering two exact pmset commands, so later toggles are silent.
one line in the terminal takes it back. read what it grants