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 {
|
} 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()
|
||||||
});
|
.for_each(|output| {
|
||||||
outputs.iter()
|
if let SwayOutput::Enabled{name,width,height,x,y} = output {
|
||||||
.for_each(|output| {
|
println!("swaymsg output {} enable dpms on mode {}x{} pos {} {}",
|
||||||
if let SwayOutput::Enabled{name,width,height,x,y} = output {
|
name, width, height, x, y);
|
||||||
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