aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index b251bab..280afb1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -7,7 +7,7 @@ struct WindowHider {
}
impl WindowHider {
- fn get_parent_term_pid(&self, pid: i32) -> Option<i32> {
+ fn get_parent_term_pid(&self, pid: i32, is_root: bool) -> Option<i32> {
let mut file = String::new();
File::open(format!("/proc/{pid}/stat")).expect("procfs stat doesn't exist").read_to_string(&mut file).unwrap();
let re = Regex::new(r"\d+ \((.*)\) (\w) (\d+) \d+").unwrap().captures(&file).unwrap();
@@ -17,20 +17,20 @@ impl WindowHider {
println!("looking for {pid}. {name}, {status}, {ppid}");
match name {
- _ if name == self.term => {
+ _ if name == self.term && !is_root => {
Some(pid)
},
_ if name == "init" => {
None
}
_ => {
- self.get_parent_term_pid(ppid)
+ self.get_parent_term_pid(ppid, false)
}
}
}
fn hide(&self, conn: &mut Connection, pid: i32) -> Result<(), swayipc::Error> {
- let ppid = self.get_parent_term_pid(pid);
+ let ppid = self.get_parent_term_pid(pid, true);
if let Some(ppid) = ppid {
println!("found parent pid of {pid} as {ppid}");
conn.run_command(format!("[pid={ppid}] mark --add {pid}, move scratchpad"))?;