add sleep arg & update readme

This commit is contained in:
e3b 2019-08-17 01:47:36 +02:00
parent dbcebf433b
commit fb1ec8ceca
2 changed files with 33 additions and 8 deletions

View File

@ -1,10 +1,12 @@
# rot8 # rot8
## automatic display rotation ## automatic display rotation using built-in accelerometer
Automatic rotate modern Linux desktop screen and input devices. Handy for Automatic rotate modern Linux desktop screen and input devices. Handy for
convertible touchscreen notebooks like the Kaby Lake model of the HP Spectre x360. 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. 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 $ cp target/release/rot8 /usr/bin/rot8
``` ```
For Sway map your input to the output device:
```
$ swaymsg <INPUTDEVICE> map_to_output <OUTPUTDEVICE>
```
Call Rote8 from sway configuration file ~/.config/sway/config: Call Rote8 from sway configuration file ~/.config/sway/config:
``` ```
exec rot8 exec rot8
``` ```
For X11 set Touchscreen Device
```
rot8 --touchscreen <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)
```

View File

@ -7,8 +7,6 @@ use std::time::Duration;
use std::process::Command; use std::process::Command;
use glob::glob; use glob::glob;
fn main() { fn main() {
let mut mode = ""; let mut mode = "";
let mut old_state = "normal"; let mut old_state = "normal";
@ -39,6 +37,12 @@ fn main() {
let matches = App::new("rot8") let matches = App::new("rot8")
.version("0.1.1") .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") .arg(Arg::with_name("display")
.default_value("eDP-1") .default_value("eDP-1")
.long("display") .long("display")
@ -46,12 +50,13 @@ fn main() {
.help("Set Display Device") .help("Set Display Device")
.takes_value(true)) .takes_value(true))
.arg(Arg::with_name("touchscreen") .arg(Arg::with_name("touchscreen")
.default_value("eDP-1") .default_value("ELAN0732:00 04F3:22E1")
.long("touchscreen") .long("touchscreen")
.value_name("TOUCHSCREEN") .value_name("TOUCHSCREEN")
.help("Set Touchscreen Device") .help("Set Touchscreen Device (X11)")
.takes_value(true)) .takes_value(true))
.get_matches(); .get_matches();
let sleep = matches.value_of("sleep").unwrap_or("default.conf");
let display = matches.value_of("display").unwrap_or("default.conf"); let display = matches.value_of("display").unwrap_or("default.conf");
let touchscreen = matches.value_of("touchscreen").unwrap_or("default.conf"); let touchscreen = matches.value_of("touchscreen").unwrap_or("default.conf");
@ -128,7 +133,6 @@ fn main() {
old_state = new_state; old_state = new_state;
} }
if mode == "x" { if mode == "x" {
Command::new("xrandr") Command::new("xrandr")
.arg("-o") .arg("-o")
.arg(x_state) .arg(x_state)
@ -148,8 +152,7 @@ fn main() {
old_state = new_state; old_state = new_state;
} }
} }
thread::sleep(Duration::from_millis(sleep));
thread::sleep(Duration::from_millis(500));
} }
} }