#screen #prevent-sleep #lock-screen #display #wake-lock

screen-wake-lock

Cross-platform library to prevent display sleep/idle using wake locks

1 unstable release

Uses new Rust 2024

0.1.0 Dec 18, 2025

#1 in #lock-screen

Download history 43/week @ 2025-12-13 104/week @ 2025-12-20 87/week @ 2025-12-27 107/week @ 2026-01-03 95/week @ 2026-01-10 95/week @ 2026-01-17 92/week @ 2026-01-24 102/week @ 2026-01-31 90/week @ 2026-02-07 101/week @ 2026-02-14 105/week @ 2026-02-21 91/week @ 2026-02-28 110/week @ 2026-03-07 104/week @ 2026-03-14 88/week @ 2026-03-21

412 downloads per month
Used in tauri-plugin-screen-wake-…

MIT license

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

Dependencies

~0.1–37MB
~626K SLoC