Skip to content

Latest commit

 

History

History
47 lines (35 loc) · 2.02 KB

README.md

File metadata and controls

47 lines (35 loc) · 2.02 KB

screenlocker

CI build state Code license Crate version Maintenance state

Screenlocker is a cross platform command line tool that locks your desktop session until a password is entered. It is also a reusable library for developers who want to perform this action programmatically.

Installation

Use Rust's cargo tool to install screenlocker.

$ cargo install screenlocker
$ screenlocker     # if $PATH contains `~/.cargo/bin`

Please contact me or create a new issue if you would like to have downloadable installers for your platform rather than use cargo.

Usage

The latest API documentation is available from a link on screenlockers's crates.io page. All you need is the lock_screen function, as seen here in this example:

use screenlocker::lock_screen;

fn main() {
    lock_screen().unwrap_or_else(|err| {
      eprintln!("{}", err);
    });
}

Building

Make sure you install Rust on your computer before building.

$ git clone https://github.com/smacdo/screenlocker.git
$ cd screenlocker
$ cargo test
$ cargo run

Multi-platform support

On Mac and Windows this crate uses the platform's native SDK to implement screen locking. Linux does not have any such functionality, and instead relies on any number of programs to lock the screen. This crate hard codes the most common programs (xdg-screensaver, gnome-screensaver-command, etc) but it is possible that less mainstream window managers don't work. Please open an issue to flag this problem - or better - a pull request adding the missing program.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.