screen-wake-lock

Crates.ioscreen-wake-lock
lib.rsscreen-wake-lock
version0.1.0
created_at2025-12-18 16:45:36.601371+00
updated_at2025-12-18 16:45:36.601371+00
descriptionCross-platform library to prevent display sleep/idle using wake locks
homepagehttps://github.com/cijiugechu/screen-wake-lock
repositoryhttps://github.com/cijiugechu/screen-wake-lock
max_upload_size
id1992832
size46,959
Cistus Creticus (cijiugechu)

documentation

README

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 SetThreadExecutionState API
  • 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
Commit count: 0

cargo fmt