https://github.com/pevers/nosleep
Cross-platform library to block the power save function in the OS
https://github.com/pevers/nosleep
caffeine nosleep powersave powersaving prevent-lock prevent-screen-lock
Last synced: about 1 year ago
JSON representation
Cross-platform library to block the power save function in the OS
- Host: GitHub
- URL: https://github.com/pevers/nosleep
- Owner: pevers
- Created: 2022-04-19T18:44:40.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-03-17T17:42:54.000Z (over 2 years ago)
- Last Synced: 2025-03-17T19:21:22.087Z (over 1 year ago)
- Topics: caffeine, nosleep, powersave, powersaving, prevent-lock, prevent-screen-lock
- Language: Rust
- Homepage:
- Size: 43.9 KB
- Stars: 10
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nosleep
[](https://github.com/pevers/nosleep/actions/workflows/mac.yml) [](https://github.com/pevers/nosleep/actions/workflows/linux.yaml) [](https://github.com/pevers/nosleep/actions/workflows/windows.yaml) [](https://crates.io/crates/nosleep/) [](https://crates.io/crates/nosleep/) 
Cross-platform library to block the power save function in the OS.
```rust
use nosleep::{NoSleep, NoSleepTrait};
let mut nosleep = NoSleep::new().unwrap();
nosleep
.prevent_display_sleep() // or prevent_system_sleep()
.unwrap();
std::thread::sleep(std::time::Duration::from_millis(180_000));
nosleep.stop().unwrap(); // Not strictly needed
```
## Supported Platforms
| Platform | Status | Tested |
|----------|--------|--------|
| Linux | ✔️ | ✔️ |
| macOS | ✔️ | ✔️ |
| Windows | ✔️ | ✔️ |
| iOS | ❌ | ❌ |
| Android | ❌ | ❌ |