From fb1ec8ceca62804d8e8eebba492e6291ad8b04f1 Mon Sep 17 00:00:00 2001 From: e3b Date: Sat, 17 Aug 2019 01:47:36 +0200 Subject: [PATCH] :heavy_plus_sign: add sleep arg & update readme --- README.md | 24 +++++++++++++++++++++++- src/main.rs | 17 ++++++++++------- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d91bbf2..dba5453 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ # rot8 -## automatic display rotation +## automatic display rotation using built-in accelerometer Automatic rotate modern Linux desktop screen and input devices. Handy for convertible touchscreen notebooks like the Kaby Lake model of the HP Spectre x360. +Compatible with [sway](http://swaywm.org/) and [X11](https://www.x.org/wiki/Releases/7.7/). + Rust language and the cargo package manager are required to build the binary. ``` @@ -13,8 +15,28 @@ $ cd rot8 && cargo build --release $ cp target/release/rot8 /usr/bin/rot8 ``` +For Sway map your input to the output device: + +``` +$ swaymsg map_to_output +``` + Call Rote8 from sway configuration file ~/.config/sway/config: ``` exec rot8 ``` + +For X11 set Touchscreen Device + +``` +rot8 --touchscreen +``` + +there are the following args. + +``` +--sleep // Set sleep millis (500) +--display // Set Display Device (eDP-1) +--touchscreen // Set Touchscreen Device X11 (ELAN0732:00 04F3:22E1) +``` diff --git a/src/main.rs b/src/main.rs index 591a6f6..2a515cd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,8 +7,6 @@ use std::time::Duration; use std::process::Command; use glob::glob; - - fn main() { let mut mode = ""; let mut old_state = "normal"; @@ -39,6 +37,12 @@ fn main() { let matches = App::new("rot8") .version("0.1.1") + .arg(Arg::with_name("sleep") + .default_value("500") + .long("sleep") + .value_name("SLEEP") + .help("Set sleep millis") + .takes_value(true)) .arg(Arg::with_name("display") .default_value("eDP-1") .long("display") @@ -46,12 +50,13 @@ fn main() { .help("Set Display Device") .takes_value(true)) .arg(Arg::with_name("touchscreen") - .default_value("eDP-1") + .default_value("ELAN0732:00 04F3:22E1") .long("touchscreen") .value_name("TOUCHSCREEN") - .help("Set Touchscreen Device") + .help("Set Touchscreen Device (X11)") .takes_value(true)) .get_matches(); + let sleep = matches.value_of("sleep").unwrap_or("default.conf"); let display = matches.value_of("display").unwrap_or("default.conf"); let touchscreen = matches.value_of("touchscreen").unwrap_or("default.conf"); @@ -128,7 +133,6 @@ fn main() { old_state = new_state; } if mode == "x" { - Command::new("xrandr") .arg("-o") .arg(x_state) @@ -148,8 +152,7 @@ fn main() { old_state = new_state; } } - - thread::sleep(Duration::from_millis(500)); + thread::sleep(Duration::from_millis(sleep)); } }