diff --git a/Cargo.lock b/Cargo.lock index e471d23..bdaf8c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -71,7 +71,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "wlstreamer" -version = "0.2.0" +version = "0.3.0" dependencies = [ "serde 1.0.117 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.59 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/src/main.rs b/src/main.rs index a0ffd12..f519f28 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ use serde::{Deserialize, Serialize}; +use std::cmp::Ordering; use std::env; use std::io::{BufRead, BufReader, Error}; use std::process::{Child, Command, Stdio}; @@ -146,7 +147,15 @@ fn get_valid_screens_for_recording(config: &Config) -> Vec { } } - workspaces.sort_by_key(|w| w.focused); + workspaces.sort_by(|a, b| { + if a.focused && !b.focused { + Ordering::Less + } else if a.focused == b.focused { + Ordering::Equal + } else { + Ordering::Greater + } + }); return workspaces.into_iter().map(|w| w.output).collect(); }