From e5cea6701f828984843998c38f460d79ffed05f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20B=C3=A4dorf?= Date: Thu, 19 Nov 2020 21:19:35 +0100 Subject: [PATCH] Dynamic resolutions seems to be working --- src/main.rs | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/main.rs b/src/main.rs index e8df36f..5285f27 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,6 +5,7 @@ use std::collections::HashMap; use std::env; use std::io::{BufRead, BufReader, Error}; use std::process::{Child, Command, Stdio}; +use std::{thread, time}; #[derive(Serialize, Deserialize, Clone, Debug)] struct SwayScreenRect { @@ -62,7 +63,7 @@ struct Resolution { struct Config { current_output: String, devices_from: usize, - current_device_index: usize, + last_device_index: usize, screen_blacklist: Vec, workspace_blacklist: Vec, verbose: bool, @@ -154,11 +155,9 @@ fn record_screen(config: &mut Config, output: SwayOutput) -> Result *device_number, None => { - config - .outputs - .insert(resolution, config.current_device_index); - config.current_device_index += 1; - config.current_device_index + config.last_device_index += 1; + config.outputs.insert(resolution, config.last_device_index); + config.last_device_index } }; @@ -198,6 +197,11 @@ fn record_screen(config: &mut Config, output: SwayOutput) -> Result Result Result<(), Box> { let mut config = Config { current_output: "".to_string(), devices_from: 0, - current_device_index: 0, + last_device_index: 0, screen_blacklist: Vec::new(), workspace_blacklist: Vec::new(), verbose: false, @@ -391,7 +394,6 @@ fn main() -> Result<(), Box> { } else if arg == "-d" || arg == "--devices-from" { i += 1; config.devices_from = args[i].clone().parse::().unwrap(); - config.current_device_index = config.devices_from; } else if arg == "--verbose" { config.verbose = true; } else if arg == "-v" || arg == "--version" { @@ -410,7 +412,7 @@ fn main() -> Result<(), Box> { config .outputs .insert(config.resolutions[0], config.devices_from); - config.current_device_index += 1; + config.last_device_index = config.devices_from; let valid_screens = get_valid_screens_for_recording(&config); let mut recorders: Vec> = if valid_screens.len() == 0 { stream_black(&mut config)?