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,22 +70,29 @@ fn main() {
});
});
} else {
println!("unknown state, do nothing")
println!("unknown state, do nothing");
}
}
// TODO if there are no enables do nothing.
outputs.iter()
.for_each(|output| {
if let SwayOutput::Disabled{name} = output {
println!("swaymsg output {} disabled", name);
}
});
outputs.iter()
.for_each(|output| {
if let SwayOutput::Enabled{name,width,height,x,y} = output {
println!("swaymsg output {} enable dpms on mode {}x{} pos {} {}",
name, width, height, x, y);
}
});
let enabled_count = outputs.iter()
.filter(|output| matches!(output,SwayOutput::Enabled{name:_,width:_,height:_,x:_,y:_}))
.count();
if enabled_count >= 1 {
// enable then disable
outputs.iter()
.for_each(|output| {
if let SwayOutput::Enabled{name,width,height,x,y} = output {
println!("swaymsg output {} enable dpms on mode {}x{} pos {} {}",
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");
}
}