adding short arguments

This commit is contained in:
e3b 2020-01-04 23:40:30 +01:00
parent 585dcab39b
commit 2190524a38
1 changed files with 27 additions and 21 deletions

View File

@ -121,7 +121,7 @@ struct Orientation {
vector: (f32, f32),
new_state: &'static str,
x_state: &'static str,
matrix: [&'static str; 9]
matrix: [&'static str; 9],
}
fn main() -> Result<(), String> {
@ -151,27 +151,31 @@ fn main() -> Result<(), String> {
Arg::with_name("sleep")
.default_value("500")
.long("sleep")
.short("s")
.value_name("SLEEP")
.help("Set sleep millis")
.takes_value(true),
Arg::with_name("display")
.default_value("eDP-1")
.long("display")
.short("d")
.value_name("DISPLAY")
.help("Set Display Device")
.takes_value(true),
Arg::with_name("touchscreen")
.default_value("ELAN0732:00 04F3:22E1")
.long("touchscreen")
.short("i")
.value_name("TOUCHSCREEN")
.help("Set Touchscreen Device (X11)")
.help("Set Touchscreen input Device (X11 only)")
.takes_value(true),
Arg::with_name("threshold")
.default_value("0.5")
.long("threshold")
.short("t")
.value_name("THRESHOLD")
.help("Set a rotation threshold between 0 and 1")
.takes_value(true)
.takes_value(true),
];
match backend {
@ -181,15 +185,13 @@ fn main() -> Result<(), String> {
.long("disable-keyboard")
.short("k")
.help("Disable keyboard for tablet modes (Sway only)")
.takes_value(false)
.takes_value(false),
);
}
Backend::Xorg => { /* Keyboard disabling in Xorg is not supported yet */ }
}
let cmd_lines = App::new("rot8")
.version("0.1.1")
.args(&args);
let cmd_lines = App::new("rot8").version("0.1.1").args(&args);
let matches = cmd_lines.get_matches();
@ -225,26 +227,26 @@ fn main() -> Result<(), String> {
vector: (0.0, -1.0),
new_state: "normal",
x_state: "normal",
matrix: ["1", "0", "0", "0", "1", "0", "0", "0", "1"]
matrix: ["1", "0", "0", "0", "1", "0", "0", "0", "1"],
},
Orientation {
vector: (0.0, 1.0),
new_state: "180",
x_state: "inverted",
matrix: ["-1", "0", "1", "0", "-1", "1", "0", "0", "1"]
matrix: ["-1", "0", "1", "0", "-1", "1", "0", "0", "1"],
},
Orientation {
vector: (-1.0, 0.0),
new_state: "90",
x_state: "right",
matrix: ["0", "-1", "1", "1", "0", "0", "0", "0", "1"]
matrix: ["0", "-1", "1", "1", "0", "0", "0", "0", "1"],
},
Orientation {
vector: (1.0, 0.0),
new_state: "270",
x_state: "left",
matrix: ["0", "1", "0", "-1", "0", "1", "0", "0", "1"]
}
matrix: ["0", "1", "0", "-1", "0", "1", "0", "0", "1"],
},
];
let mut current_orient: &Orientation = &orientations[0];
@ -272,7 +274,11 @@ fn main() -> Result<(), String> {
matrix = current_orient.matrix;
if new_state != old_state {
let keyboard_state = if new_state == "normal" { "enabled" } else { "disabled" };
let keyboard_state = if new_state == "normal" {
"enabled"
} else {
"disabled"
};
match backend {
Backend::Sway => {
Command::new("swaymsg")