Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use top-level config as fallback when using monitor-based config #373

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 5 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use gtk::gdk::Display;
use gtk::prelude::*;
use gtk::Application;
use lazy_static::lazy_static;

Check warning on line 24 in src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

unused import: `lazy_static::lazy_static`

warning: unused import: `lazy_static::lazy_static` --> src/main.rs:24:5 | 24 | use lazy_static::lazy_static; | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default
use tokio::runtime::Handle;
use tokio::task::{block_in_place, spawn_blocking};
use tracing::{debug, error, info, warn};
Expand Down Expand Up @@ -228,7 +228,7 @@
|display| display,
);

let mut config = env::var("IRONBAR_CONFIG")

Check warning on line 231 in src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

variable does not need to be mutable

warning: variable does not need to be mutable --> src/main.rs:231:9 | 231 | let mut config = env::var("IRONBAR_CONFIG") | ----^^^^^^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` on by default
.map_or_else(
|_| ConfigLoader::new("ironbar").find_and_load(),
ConfigLoader::load,
Expand Down Expand Up @@ -276,6 +276,9 @@

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 +309,13 @@
.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
Loading