https://github.com/compnerd/vigil
A `caffeinate` inspired power management suspension program for Windows
https://github.com/compnerd/vigil
Last synced: 4 months ago
JSON representation
A `caffeinate` inspired power management suspension program for Windows
- Host: GitHub
- URL: https://github.com/compnerd/vigil
- Owner: compnerd
- License: bsd-3-clause
- Created: 2025-08-28T15:41:33.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-09-22T04:14:03.000Z (9 months ago)
- Last Synced: 2025-12-27T07:49:45.434Z (6 months ago)
- Language: Swift
- Homepage:
- Size: 15.6 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vigil
A Windows command-line tool that prevents your computer from going to sleep or turning off the display. Perfect for long-running tasks, presentations, or keeping your system active.
**Note:** Running `vigil` without arguments defaults to the `stand` command, which requires a command to execute.
## What does vigil do?
vigil temporarily overrides Windows power management settings to keep your computer awake. It offers three ways to prevent sleep:
- **`vigil start`** — Start sleep prevention that runs until you manually stop it
- **`vigil end`** — Stop a running vigil session
- **`vigil stand`** — Prevent sleep while running a specific command (default command)
## Installation
Build from source using Swift Package Manager:
```powershell
swift build --configuration release
```
The executable will be available at `.build/release/vigil.exe`.
## Basic Usage
### Keep system awake indefinitely
```powershell
# Prevent computer from sleeping due to inactivity
vigil start --idle
# Also keep the display on
vigil start --idle --display
# Stop when done
vigil end
```
### Keep system awake for a specific duration
```powershell
# Prevent sleep for 2 hours (7200 seconds)
vigil start --idle --timeout 7200
```
### Run in background (daemon mode)
```powershell
# Start background sleep prevention for 1 hour
vigil start --idle --timeout 3600 --daemonize
# The process will run in background, you can close the terminal
# To stop it early:
vigil end
```
### Prevent sleep while running a command
```powershell
# Keep system awake while running a backup
vigil stand --idle -- robocopy C:\Important D:\Backup /MIR
# Keep display on during a video conversion
vigil stand --display -- ffmpeg -i input.mp4 output.mkv
```
## Command Options
### Sleep Prevention Modes
- `--idle` / `-i` — Prevent the computer from sleeping due to inactivity
- `--display` / `-d` — Prevent the display from turning off
- `--system` / `-s` — Prevent sleep only when running on AC power (not battery)
### Additional Options
- `--timeout ` / `-t` — Automatically stop after specified seconds (only with `start`)
- `--daemonize` / `-d` — Run the `start` command in the background (requires `--timeout`)
**Note:** At least one sleep prevention mode (`--idle`, `--system`, or `--display`) must be specified.
## Common Scenarios
**Long download or upload:**
```powershell
vigil start --idle
# Run your download/upload
vigil end
```
**Background download (daemon mode):**
```powershell
vigil start --idle --timeout 14400 --daemonize # 4 hours in background
# Close terminal, download continues
vigil end # Stop early if needed
```
**Presentation or demo:**
```powershell
vigil start --display --idle
# Give your presentation
vigil end
```
**Overnight batch job:**
```powershell
vigil stand --idle -- python my_long_script.py
```
**Video call or streaming:**
```powershell
vigil start --display --system # Only when plugged in
```
## How It Works
vigil uses Windows power management APIs to temporarily change execution state:
- Requests that Windows keep the system and/or display active
- Automatically restores normal power settings when stopped
- Uses named events for communication between `start` and `end` commands
## Troubleshooting
**vigil end doesn't work:**
- Make sure you're running as the same user who ran `vigil start`
- Only one `vigil start` session can run at a time
**Computer still goes to sleep:**
- Check if other power policies (group policy, manufacturer tools) are overriding settings
- Try combining `--idle` and `--display` flags
- Verify you're using the correct flags for your scenario
**--system flag has no effect:**
- This flag only prevents sleep when on AC power
- Check your power status in Windows settings
**--daemonize requires timeout:**
- Background execution needs a timeout to prevent runaway processes
- Use `--timeout` with `--daemonize`