Git Product home page Git Product logo

caffeinate's Introduction

Caffeinate

A super simple CLI utility for keeping your PC awake.

All it does is:

SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED);
Sleep(...);

The computer is prevented from sleeping for as long as the program remains running. The display/monitor is still allowed to turn off. SetThreadExecutionState docs here.

And because it is CLI only, it can be used from session 0 (ex: from SSH connection).

Download

Download from the latest GitHub release (runs on 32 and 64bit):

Note: You may have to "unblock" the program after downloading: Right-click the exe file โ†’ Properties โ†’ Check "Unblock" at bottom right.

Usage

caffeinate.exe [duration] [--help]

The program will remain open and prevent sleep for the given duration, or forever if a duration is not given. Use SIGINT (ctrl+c), SIGHUP, SIGTERM, etc. to kill at any time.

  • Duration may be a whole number with an optional unit, or the word forever.
  • If duration is not given, forever is used.
  • Valid units: s (seconds), m (minutes), h (hours)
  • If a unit is not given, seconds is used.

Examples:

caffeinate.exe         # Forever
caffeinate.exe forever # Forever
caffeinate.exe 30      # 30 seconds
caffeinate.exe 30s     # 30 seconds
caffeinate.exe 120s    # 2 minutes
caffeinate.exe 2m      # 2 minutes
caffeinate.exe 36h     # 36 hours

WSL

Optional: Here is a small bash script for managing Caffeinate from WSL. Calling this script will kill all Caffeinate instances and start a new one in the background, thus ensuring only one is running and allowing you to reset or end the caffeinated duration.

Please modify to set the correct caffeinate.exe path and default duration as desired.

The interface nearly identical to caffeinate.exe, but the script may default the duration to a value other than forever. Also, if a duration of 0 is given, all Caffeinate instances are killed but a new one is not started.

Alternatives

  • Caffeine - If you want a GUI and lots of features.
  • Insomnia - If you want a simple GUI.

I created Caffeinate because I wanted a CLI solution that could be used from session 0. Specifically, to be able to keep my PC awake while SSH'ed into WSL.

caffeinate's People

Contributors

yo1dog avatar

Watchers

 avatar  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.