1 unstable release
Uses new Rust 2024
| 0.1.0 | Dec 18, 2025 |
|---|
#1 in #lock-screen
412 downloads per month
Used in tauri-plugin-screen-wake-…
18KB
364 lines
screen-wake-lock: minimal cross-platform "keep screen awake" guard.
Usage:
let lock = screen_wake_lock::ScreenWakeLock::acquire("Playing video")?;
// keep running...
drop(lock); // screen can sleep again
screen-wake-lock
Minimal cross-platform screen wake lock library.
Overview
This library provides a simple guard that prevents the display from entering idle/sleep mode while it remains alive. It supports Windows, macOS, and Linux.
Usage
use screen_wake_lock::ScreenWakeLock;
// Acquire a wake lock
let lock = ScreenWakeLock::acquire("Playing video")?;
// Keep running...
// The screen will stay awake while the lock is alive
// Release the lock (also happens automatically when dropped)
drop(lock);
Platform Support
- Windows: Uses
SetThreadExecutionStateAPI - macOS: Uses IOKit power management
- Linux: Uses D-Bus inhibitor service (requires a session bus)
Additional Features
- Check if wake lock is supported:
ScreenWakeLock::is_supported() - Linux-specific options:
ScreenWakeLock::acquire_with_linux_options()
Example
cargo run --example keep_awake "Watching movie" 30
Dependencies
~0.1–37MB
~626K SLoC