Skip to content

Instantly share code, notes, and snippets.

@daystram
Created March 5, 2021 20:15
Show Gist options
  • Select an option

  • Save daystram/4619a0d19265bb8bc0e70ac7e06f558d to your computer and use it in GitHub Desktop.

Select an option

Save daystram/4619a0d19265bb8bc0e70ac7e06f558d to your computer and use it in GitHub Desktop.
MacBook toggle sleep on lid close script
#!/bin/bash
set -e
FLAG="$HOME/.lidsleep"
if [[ -f $FLAG ]]; then
sudo pmset -a disablesleep 0
rm $FLAG
echo "lidsleep: enabled sleep on lid close"
else
sudo pmset -a disablesleep 1
touch $FLAG
echo "lidsleep: disabled sleep on lid close"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment