NoSleep CLI is a lightweight Windows command-line utility that prevents the system from entering sleep mode or turning off the display.
The tool signals activity directly to the Windows kernel, meaning it does not modify power plans or registry settings and restores normal behavior immediately when stopped.
- Keep Awake: Prevents system sleep and display power-off.
- Background Support: Execution tracking using a PID file.
- Timer Mode: Run for a specific duration (seconds, minutes, or hours).
- Clean Management: Dedicated
start,stop, andstatuscommands. - User-Friendly: No administrator privileges required.
- Windows 10 or later
- Uses the Win32 API function:
SetThreadExecutionState
- Python 3.8+
pipinstalled
git clone https://github.com/SupaOhm/NoSleep-CLI.git
cd NoSleep-CLI
py -m pip install .If you see a warning that nosleep.exe is installed in a directory not on PATH, follow these steps:
- Press
Win + R, type sysdm.cpl, and press Enter. - Open Advanced → Environment Variables.
- Under User variables, select Path → Edit.
- Click New and add the path provided in the warning (e.g.,
C:\Users\<your-username>\AppData\Local\Programs\Python\Python314\Scripts). - Click OK on all dialogs and restart your terminal.
- After installation, you can use the
nosleepcommand in your terminal. - For help and usage instructions, run:
nosleep --helpnosleepStarts NoSleep in the foreground. Prevents sleep until Ctrl+C.nosleep stopTerminates the running NoSleep process and removes the PID file.nosleep --statusChecks if a NoSleep process is currently active.nosleep --timer <duration>Runs NoSleep for a specified duration (e.g., 30m for 30 minutes).
- Run NoSleep for a fixed duration, after which it will stop automatically.
- Supported units:
s (seconds),m (minutes),h (hours).
nosleep --timer 30m # Stay awake for 30 minutes
nosleep --timer 2h # Stay awake for 2 hours
nosleep --timer 90s # Stay awake for 90 seconds- Win32 API Integration
- The tool utilizes
ctypesto callSetThreadExecutionStatewith the following flags: - ES_SYSTEM_REQUIRED: Forces the system to be in the working state.
- ES_DISPLAY_REQUIRED: Forces the display to be on.
- ES_CONTINUOUS: Informs Windows the state should persist until the next call or the thread ends.
- To handle tracking and safe shutdowns, NoSleep stores a PID file at:
%USERPROFILE%\.nosleep.pid - This enables background tracking and ensures that the
stopcommand can find and terminate the specific process correctly.
To remove NoSleep CLI:
py -m pip uninstall NoSleep-CLI- Windows-only: Relies on specific Win32 API calls.
- Terminal Window: The terminal must remain open while running in foreground mode.
- Hard Overrides: Does not override forced hardware shutdowns or critical battery events.
- Background daemon mode (fully detached from terminal)
- Scheduled execution support
- Windows Service implementation
- Standalone .exe distribution (via PyInstaller)