mirror of
https://gitlab.com/hyask/swaysome.git
synced 2025-12-10 07:44:43 +01:00
get_output: always filter out inactive outputs
This commit is contained in:
parent
7b3de58cd9
commit
9772931af9
1 changed files with 6 additions and 2 deletions
|
|
@ -183,7 +183,11 @@ fn get_outputs(stream: &UnixStream) -> Vec<Output> {
|
|||
Ok(msg) => msg,
|
||||
Err(_) => panic!("Unable to get outputs"),
|
||||
};
|
||||
let mut outputs: Vec<Output> = serde_json::from_str(&o).unwrap();
|
||||
let mut outputs: Vec<Output> = serde_json::from_str::<Vec<Output>>(&o)
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.filter(|x| x.active)
|
||||
.collect();
|
||||
outputs.sort_by(|x, y| x.name.cmp(&y.name)); // sort_by_key doesn't work here (https://stackoverflow.com/a/47126516)
|
||||
outputs
|
||||
}
|
||||
|
|
@ -559,7 +563,7 @@ fn init_workspaces(stream: &UnixStream, workspace_index: usize) {
|
|||
let outputs = get_outputs(stream);
|
||||
|
||||
let cmd_prefix: String = "focus output ".to_string();
|
||||
for output in outputs.iter().filter(|x| x.active).rev() {
|
||||
for output in outputs.iter().rev() {
|
||||
let mut cmd = cmd_prefix.clone();
|
||||
cmd.push_str(output.name.as_str());
|
||||
send_command(stream, &cmd);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue