enabled then disable, only if at least one enabled

This commit is contained in:
2023-09-22 19:07:43 -04:00
parent 19d0f8be6a
commit f0496d20de

View File

@@ -70,17 +70,15 @@ fn main() {
}); });
}); });
} else { } else {
println!("unknown state, do nothing") println!("unknown state, do nothing");
} }
} }
// TODO if there are no enables do nothing. let enabled_count = outputs.iter()
outputs.iter() .filter(|output| matches!(output,SwayOutput::Enabled{name:_,width:_,height:_,x:_,y:_}))
.for_each(|output| { .count();
if let SwayOutput::Disabled{name} = output { if enabled_count >= 1 {
println!("swaymsg output {} disabled", name); // enable then disable
}
});
outputs.iter() outputs.iter()
.for_each(|output| { .for_each(|output| {
if let SwayOutput::Enabled{name,width,height,x,y} = output { if let SwayOutput::Enabled{name,width,height,x,y} = output {
@@ -88,4 +86,13 @@ fn main() {
name, width, height, x, y); name, width, height, x, y);
} }
}); });
outputs.iter()
.for_each(|output| {
if let SwayOutput::Disabled{name} = output {
println!("swaymsg output {} disabled", name);
}
});
} else {
println!("No enabled outputs, do nothing");
}
} }