enabled then disable, only if at least one enabled
This commit is contained in:
37
src/main.rs
37
src/main.rs
@@ -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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user