Giter VIP home page Giter VIP logo

wake's Introduction

wake

Macbooks always go to sleep when the lid is closed, unless they are plugged in to an external monitor. There exists a hidden command pmset disablesleep which disables the sleep feature.

My wake.sh script calls this command to prevent the Macbook from going to sleep and reverts it when the script exits.

pmset disablesleep

If you want to permanently disable sleep, or just test out the command yourself:

Disable sleep: sudo pmset disablesleep 1

Enable sleep: sudo pmset disablesleep 0

One side effect, at least on my machine, is that the keyboard backlight doesn't turn back on after closing and re-opening the lid when sleep is disabled. Adjusting the keyboard brightness turns it back on though.

wake.sh

The script is a simple wrapper for the above commands. It's intended for temporarily disabling sleep, so it turns sleep back on when the script exits.

Setup

1. Give executable permissions

In order to run the script, give the script executable permission with chmod +x wake.sh.

It can now be run from Terminal in the same directory with sudo ./wake.sh.

2. Make script global (optional)

If you want to run the script from anywhere add it to /usr/local/bin. Or, save it wherever you want and make a link to it with ln -s /path/to/wake.sh /usr/local/bin/wake.

It can now be run from Terminal with sudo wake.

3. Remove pmset password requirement (optional)

The power management command pmset requires sudo to run. If you don't want to enter your password each time you can set it to not require password for your user.

  1. Open Terminal
  2. Open the sudo configuration editor with sudo visudo.
  3. Add to the end of the file <user> ALL=(ALL) NOPASSWD: /usr/bin/pmset where <user> is your username.
  4. Save changes with :wq.

It can now be run from Terminal with wake, or by clicking on the script in Finder.

wake's People

Contributors

moarram avatar pfra17 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.