Skip to content

Commit

Permalink
feat: use top-level config as fallback when using monitor-based config
Browse files Browse the repository at this point in the history
This allows you to configure a default bar to use, then override specific monitors.

Not setting anything at the top level will hide bars which are not explicitly configured.

This actually came about as a bug in the recent refactorings, but now it's a feature :)
  • Loading branch information
JakeStanger committed Dec 10, 2023
1 parent 56f423e commit 4a8ee3a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion docs/Configuration guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ Create a map/object called `monitors` inside the top-level object.
Each of the map's keys should be an output name,
and each value should be an object containing the bar config.

To find your output names, run `wayland-info | grep wl_output -A1`.
You can still define a top-level "default" config to use for unspecified monitors.
Alternatively, leave the top-level `start`, `center` and `end` keys null to hide bars on unspecified monitors.

> [!TIP]
> To find your output names, run `wayland-info | grep wl_output -A1`.
<details>
<summary>JSON</summary>
Expand Down
5 changes: 4 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ fn create_bars(app: &Application, display: &Display, config: &Config) -> Result<

let num_monitors = display.n_monitors();

let show_default_bar = config.start.is_some() || config.center.is_some() || config.end.is_some();

let mut all_bars = vec![];
for i in 0..num_monitors {
let monitor = display
Expand Down Expand Up @@ -306,12 +308,13 @@ fn create_bars(app: &Application, display: &Display, config: &Config) -> Result<
.iter()
.map(|config| create_bar(app, &monitor, monitor_name.to_string(), config.clone()))
.collect::<Result<_>>()?,
None => vec![create_bar(
None if show_default_bar =>vec![create_bar(
app,
&monitor,
monitor_name.to_string(),
config.clone(),
)?],
None => vec![]
};

all_bars.append(&mut bars);
Expand Down

0 comments on commit 4a8ee3a

Please sign in to comment.