From eaff81588f1f4a083a188276ad23fcaaae60bc39 Mon Sep 17 00:00:00 2001 From: Cyril Levis Date: Wed, 22 Nov 2023 15:36:10 +0100 Subject: [PATCH] feat: add a new max_clients config param --- src/config/mod.rs | 3 +++ src/renamer/formatter.rs | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/src/config/mod.rs b/src/config/mod.rs index aa2fe1d..5d9ffed 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -67,6 +67,8 @@ impl Default for ConfigFormatRaw { #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)] pub struct ConfigFormatRaw { + #[serde(default)] + pub max_clients: Option, #[serde(default)] pub dedup: bool, #[serde(default)] @@ -263,6 +265,7 @@ version = "1.1.11" # dedup_inactive_fullscreen = false # dedup more # window delimiter # delim = " " +# max_clients = 30 # available formatter: # {counter_sup} - superscripted count of clients on the workspace, and simple {counter}, {delim} diff --git a/src/renamer/formatter.rs b/src/renamer/formatter.rs index eab9282..5158aa3 100644 --- a/src/renamer/formatter.rs +++ b/src/renamer/formatter.rs @@ -31,6 +31,12 @@ impl Renamer { let workspace_output = counted .iter_mut() .map(|(client, counter)| self.handle_new_client(client, *counter, config)) + .take( + config + .format + .max_clients + .map_or(usize::MAX, |max| max as usize), + ) .collect::>(); let delimiter = formatter("{delim}", &vars);