14 releases

0.5.1 Feb 11, 2024
0.4.5 Nov 8, 2023
0.4.3 Jun 9, 2023
0.4.1 Feb 26, 2023
0.3.0 Nov 29, 2022

#974 in Command line utilities

Download history 49/week @ 2024-08-04 2/week @ 2024-08-11 5/week @ 2024-08-18 1/week @ 2024-08-25 11/week @ 2024-09-01 10/week @ 2024-09-08 12/week @ 2024-09-15 154/week @ 2024-09-22 60/week @ 2024-09-29 13/week @ 2024-10-06 39/week @ 2024-10-13 31/week @ 2024-10-20 33/week @ 2024-10-27 17/week @ 2024-11-03

121 downloads per month
Used in 3 crates

MIT license

27KB
452 lines

keepawake-rs

Crates.io docs.rs CI

Keep your computer awake. Like caffeinate, systemd-inhibit/gnome-session-inhibit, or PowerToys Awake, but cross-platform and written in Rust.

Also available as a Rust crate, and as a C library (experimental).

Usage

Keep your computer awake

Usage: keepawake [OPTIONS] [COMMAND]...

Arguments:
  [COMMAND]...  Run the command and wait for it to exit, keeping the computer awake while it runs

Options:
  -d, --display              Keep display on
  -i, --idle                 Keep system from idle sleeping
  -s, --sleep                Keep system from sleeping (Functionality and conditions for this to work vary by OS)
      --completions <SHELL>  Generate shell completions [possible values: bash, elvish, fish, powershell, zsh]
  -w <PID>                   Wait for the process with the specified pid to exit. This option is ignored when used with the COMMAND argument
  -h, --help                 Print help information
  -V, --version              Print version information

See docs.rs/keepawake for library crate documentation and usage.

Installation

Cargo

cargo install keepawake -F bin

Binaries

Download from https://github.com/segevfiner/keepawake-rs/releases/latest.

Completions

Use: keepawake --completions <SHELL> to generate a completion script, you will have to install it as appropriate for the specific shell you are using.

C library (experimental)

Built using cargo-c.

# build the library, create the .h header, create the .pc file
$ cargo cbuild --destdir=${D} --prefix=/usr --libdir=/usr/lib64
# build the library, create the .h header, create the .pc file and install all of it
$ cargo cinstall --destdir=${D} --prefix=/usr --libdir=/usr/lib64

See the generated header file for details on the API. See cargo-c for futher details on cargo-c usage.

Notes

Preventing the computer from explicitly sleeping, and/or by closing the lid, is often restricted in various ways by the OS, e.g. Only on AC power, not in any PC running Windows with Modern Standby. Also note that Modern Standby ignores/terminates power requests on DC (Battery) power, PowerSetRequest - Remarks.

License

MIT License.

Dependencies

~0.8–45MB
~718K SLoC