While this would be a pain if you're using your laptop in a meeting, it will be a lifesaver if you forgot and put your laptop in your bag to go home.Īstute readers will note that these commands require sudo sadly, that's unavoidable AFAIK. It will also set a timeout (defaults to 300 seconds/5 minutes) after which the sleep settings will automatically be re-enabled, and the laptop will be forced to go to sleep. The shell script will disable sleeping until you hit the Enter key, at which point it will re-enable the sleep settings (alternately, you can hit Ctrl- C and achieve the same thing). #- insert a newline for timeout or Ctrl-C -Įcho "Restoring previous battery sleep setting: $BATTERY_SLEEP" #*** noz - prevent laptop from sleeping when lid is closedĮcho -n "Preventing sleep for $timeout_len seconds press to continue." Because of this, I've written a shell script to automatically re-enable the settings: #!/bin/bash This is a bit dangerous, since if you forget to re-enable your settings, the laptop will never sleep when on battery. The "5" in the second set of commands represents the number of minutes before sleeping when on battery adjust as desired for your laptop. To re-enable laptop sleeping when the lid is closed and you're running on battery, run the following commands: sudo pmset -b sleep 5 sudo pmset -b disablesleep 0 To prevent the laptop from sleeping when the lid is closed and you're running on battery, run the following commands: sudo pmset -b sleep 0 sudo pmset -b disablesleep 1
0 Comments
Leave a Reply. |