1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-07-02 19:21:03 +02:00

feat: support for multiple bars per monitor, loading config from env var

Restructures `monitor` config key into object of monitor names -> configs.
This commit is contained in:
Jake Stanger 2022-08-15 17:06:42 +01:00
parent 001dd5473a
commit 2d755d37e5
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
2 changed files with 63 additions and 34 deletions

View file

@ -8,7 +8,7 @@ mod style;
mod sway;
use crate::bar::create_bar;
use crate::config::Config;
use crate::config::{Config, MonitorConfig};
use crate::style::load_css;
use crate::sway::SwayOutput;
use dirs::config_dir;
@ -40,6 +40,7 @@ async fn main() {
let display = gdk::Display::default().expect("Failed to get default GDK display");
let num_monitors = display.n_monitors();
for i in 0..num_monitors {
let monitor = display.monitor(i).unwrap();
let monitor_name = &outputs
@ -47,11 +48,22 @@ async fn main() {
.expect("GTK monitor output differs from Sway's")
.name;
let config = config.monitors.as_ref().map_or(&config, |monitor_config| {
monitor_config.get(i as usize).unwrap_or(&config)
});
create_bar(app, &monitor, monitor_name, config.clone());
if let Some(ref config) = config.monitors {
let config = config.get(monitor_name);
match &config {
Some(MonitorConfig::Single(config)) => {
create_bar(app, &monitor, monitor_name, config.clone());
}
Some(MonitorConfig::Multiple(configs)) => {
for config in configs {
create_bar(app, &monitor, monitor_name, config.clone());
}
}
_ => {}
}
} else {
create_bar(app, &monitor, monitor_name, config.clone());
}
}
let style_path = config_dir()