From 82747cc5537042929a13a18f83ace60a489dc7e4 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 --- README.md | 1 + src/config/mod.rs | 3 +++ src/renamer/formatter.rs | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/README.md b/README.md index 4e11858..080c130 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,7 @@ clients: ``` [format] +# max_clients = 10 (default: usize::MAX) dedup = true dedup_inactive_fullscreen = true delim = " " # NARROW NO-BREAK SPACE 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);