aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorAnna (navi) Figueiredo Gomes <navi@vlhl.dev>2023-09-25 16:09:11 +0200
committerAnna (navi) Figueiredo Gomes <navi@vlhl.dev>2023-09-25 16:09:11 +0200
commit0dedd834dc8d123ae2c4043a0df841656931df98 (patch)
tree8c80ffde4b63f05bf521cd736b99ec477c93dc03 /src/main.rs
parentc9023294887ec5fe80d4cd87fa42330b9c5f84a8 (diff)
add support for multiple terminals at once
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index 3c35738..f9f3f36 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,7 +3,7 @@ use std::{env,fs::File, io::{Read, self}, num, fmt::Display};
use regex::Regex;
struct WindowHider {
- term: String,
+ term: Vec<String>,
regex: Regex,
}
@@ -56,7 +56,7 @@ impl WindowHider {
match name {
"init" => Ok(None),
- _ if name == self.term && !is_root => Ok(Some(pid)),
+ _ if self.term.contains(&name.to_string()) && !is_root => Ok(Some(pid)),
_ => self.get_parent_term_pid(ppid, false)
}
}
@@ -84,14 +84,15 @@ fn main() -> Result<(), swayipc::Error> {
// running commands. :(
let mut args: Vec<String> = env::args().collect();
+ let nterms = args.len() - 1;
- if args.len() < 2 {
- println!("usage: swhd <terminal>");
+ if nterms < 1 {
+ println!("usage: swhd <list of terminals>");
return Ok(());
}
let wh = WindowHider {
- term: args.remove(1),
+ term: args.drain(1..nterms).collect(),
regex: Regex::new(r"\d+ \((.*)\) \w (\d+) \d+").unwrap()
};