mirror of
https://github.com/house-of-vanity/swkb.git
synced 2025-07-07 03:14:06 +00:00
Got rid of some unwraps.
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -536,7 +536,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "swkb"
|
name = "swkb"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-std",
|
"async-std",
|
||||||
"failure",
|
"failure",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "swkb"
|
name = "swkb"
|
||||||
version = "0.2.1"
|
version = "0.2.2"
|
||||||
authors = ["Alexandr Bogomyakov <abogomyakov@iponweb.net>"]
|
authors = ["Alexandr Bogomyakov <abogomyakov@iponweb.net>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
17
src/main.rs
17
src/main.rs
@ -7,10 +7,14 @@ use swayipc::{Connection, EventType, Fallible};
|
|||||||
|
|
||||||
async fn get_input_id() -> Vec<String> {
|
async fn get_input_id() -> Vec<String> {
|
||||||
let mut connection = Connection::new().await.unwrap();
|
let mut connection = Connection::new().await.unwrap();
|
||||||
let inputs = connection.get_inputs().await.unwrap();
|
|
||||||
let mut ids: Vec<String> = Vec::new();
|
let mut ids: Vec<String> = Vec::new();
|
||||||
for i in inputs {
|
match connection.get_inputs().await {
|
||||||
ids.push(i.identifier);
|
Ok(inputs) => {
|
||||||
|
for i in inputs {
|
||||||
|
ids.push(i.identifier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
ids
|
ids
|
||||||
}
|
}
|
||||||
@ -49,8 +53,11 @@ async fn main() -> Fallible<()> {
|
|||||||
match event {
|
match event {
|
||||||
Ok(Event::Input(event)) => {
|
Ok(Event::Input(event)) => {
|
||||||
let layouts_list = event.input.xkb_layout_names;
|
let layouts_list = event.input.xkb_layout_names;
|
||||||
let layout_name = event.input.xkb_active_layout_name.unwrap();
|
let layout_name = event.input.xkb_active_layout_name.unwrap_or("none".to_string());
|
||||||
let index = layouts_list.iter().position(|r| *r == layout_name).unwrap() as i64;
|
if layout_name == "none" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
let index = layouts_list.iter().position(|r| *r == layout_name).unwrap_or(0) as i64;
|
||||||
let mut layouts = layouts.lock().unwrap();
|
let mut layouts = layouts.lock().unwrap();
|
||||||
let current_window = get_focus_id().await;
|
let current_window = get_focus_id().await;
|
||||||
//println!("Layout saved [{:?}] for {:?}", layout_name, current_window);
|
//println!("Layout saved [{:?}] for {:?}", layout_name, current_window);
|
||||||
|
Reference in New Issue
Block a user