[GH-ISSUE #537] Multiple bar across all monitors #1581

Closed
opened 2026-05-22 22:53:16 +01:00 by JakeStanger · 2 comments
Owner

Originally created by @huyufeifei on GitHub (Apr 9, 2024).
Original GitHub issue: https://github.com/JakeStanger/ironbar/issues/537

I have two monitors and I want to show two bars (top and bottom) in each monitor. Contents of bars in the same position but different monitor should be the same(e.g. top bar in monitor-1 and top bar in monitor-2).

I know there is a way to configure it, as below:

{
  "monitors": {
    "monitor-1": [
      { "position": "top", ... },
      { "position": "bottom", ... }
    ],
    "monitor-2": [
      { "position": "top", ... },
      { "position": "bottom", ... }
    ]
  }
}

but this is not very graceful, since I need to repeat the same object multiple times.

I want to know whether there is a way to set a "default" bars config for every monitors which supports multiple bars. Current way seems only support one bar as default.

Originally created by @huyufeifei on GitHub (Apr 9, 2024). Original GitHub issue: https://github.com/JakeStanger/ironbar/issues/537 I have two monitors and I want to show two bars (top and bottom) in each monitor. Contents of bars in the same position but different monitor should be the same(e.g. top bar in monitor-1 and top bar in monitor-2). I know there is a way to configure it, as below: ```json { "monitors": { "monitor-1": [ { "position": "top", ... }, { "position": "bottom", ... } ], "monitor-2": [ { "position": "top", ... }, { "position": "bottom", ... } ] } } ``` but this is not very graceful, since I need to repeat the same object multiple times. I want to know whether there is a way to set a "default" bars config for every monitors which supports multiple bars. Current way seems only support one bar as default.
Author
Owner

@JakeStanger commented on GitHub (Apr 9, 2024):

Hey, there is no way to do this with JSON or TOML. YAML possibly has some templating features built in, although I've never tested if the Rust implementation includes them.

This can however be easily done with the Corn format and its inputs mechanism:

let {
  $bar = { start = [] center = [] end = [] }

  $bars = [
    { position = "top" ..$bar } 
    { position = "bottom" ..$bar } 
  ]
} in {
  monitors.monitor-1 = $bars
  monitors.monitor-2 = $bars
}
<!-- gh-comment-id:2044522620 --> @JakeStanger commented on GitHub (Apr 9, 2024): Hey, there is no way to do this with JSON or TOML. YAML [possibly](https://en.wikipedia.org/wiki/YAML#Advanced_components) has some templating features built in, although I've never tested if the Rust implementation includes them. This can however be easily done with the [Corn](https://cornlang.dev/) format and its inputs mechanism: ```corn let { $bar = { start = [] center = [] end = [] } $bars = [ { position = "top" ..$bar } { position = "bottom" ..$bar } ] } in { monitors.monitor-1 = $bars monitors.monitor-2 = $bars }
Author
Owner

@huyufeifei commented on GitHub (Apr 9, 2024):

Thanks for reply! It works fine.

<!-- gh-comment-id:2045382747 --> @huyufeifei commented on GitHub (Apr 9, 2024): Thanks for reply! It works fine.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
JakeStanger/ironbar#1581
No description provided.