Skip to content

Commit

Permalink
feat: add a new max_clients config param (wip) (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrinux authored Nov 24, 2023
1 parent c097cbb commit d2269ed
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ clients:

```
[format]
# max_clients = 10 (default: usize::MAX)
dedup = true
dedup_inactive_fullscreen = true
delim = " " # NARROW NO-BREAK SPACE
Expand Down
3 changes: 3 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ impl Default for ConfigFormatRaw {

#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
pub struct ConfigFormatRaw {
#[serde(default)]
pub max_clients: Option<i32>,
#[serde(default)]
pub dedup: bool,
#[serde(default)]
Expand Down Expand Up @@ -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}
Expand Down
6 changes: 6 additions & 0 deletions src/renamer/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<String>>();

let delimiter = formatter("{delim}", &vars);
Expand Down

0 comments on commit d2269ed

Please sign in to comment.