configurations things

This commit is contained in:
2026-09-13 18:32:37 +01:00
parent a14b6f4967
commit cc67cd25e9
9 changed files with 122 additions and 27 deletions
+8
View File
@@ -13,6 +13,10 @@ pub(crate) struct Bar {
pub(crate) modules: BTreeMap<&'static str, Box<dyn BarModule>>,
/// Left, Middle, Right ; Module Order
pub(crate) order: (Vec<Modules>, Vec<Modules>, Vec<Modules>),
/// Left/right padding between the bar edge and its content.
pub(crate) padding: f32,
/// Gap between modules in the bar.
pub(crate) spacing: f32,
/// Surface id of the open popup.
pub(crate) popup_id: Option<window::Id>,
/// Fan-out routing table: module id -> services it wants.
@@ -26,6 +30,8 @@ impl Bar {
pub(crate) fn new(
modules_config_table: &Table,
modules_order: (Vec<Modules>, Vec<Modules>, Vec<Modules>),
padding: f32,
spacing: f32,
) -> Self {
// Registry owns construction: adding a module never edits this file.
let modules: BTreeMap<&'static str, Box<dyn BarModule>> =
@@ -53,6 +59,8 @@ impl Bar {
active_popup: None,
modules,
order: modules_order,
padding,
spacing,
popup_id: None,
routes,
inputs,
+7 -22
View File
@@ -10,8 +10,6 @@ use std::io::Read;
use clap::Parser;
use common::BarbarConfig;
use iced_layershell::daemon;
use iced_layershell::reexport::Anchor;
use iced_layershell::settings::{LayerShellSettings, Settings, StartMode};
mod app;
mod args;
@@ -24,9 +22,6 @@ mod view;
pub(crate) use app::Bar;
pub(crate) use msg::{Message, Msg};
/// Height of the bar in logical pixels.
const BAR_HEIGHT: u32 = 36;
/// Default log filter per build profile. Debug builds log barbar's own crates
/// at `debug` while dependency noise (iced_layershell/sctk/cosmic_text/wgpu…)
/// stays at `warn`; release builds log `warn` and above. `RUST_LOG` overrides.
@@ -56,14 +51,12 @@ fn main() -> Result<(), iced_layershell::Error> {
return Ok(());
}
let start_mode = match &config.monitor {
Some(x) => StartMode::TargetScreen(x.clone()),
None => StartMode::Active,
};
let modules = config.modules.clone().unwrap_or_default();
let order = config.order;
tracing::info!(monitor = ?config.monitor, "starting barbar daemon");
let disp = config.display;
tracing::info!(monitor = ?disp.monitor, "starting barbar daemon");
let (padding, spacing) = (disp.padding, disp.spacing);
let settings = disp.settings();
daemon(
move || {
@@ -74,6 +67,8 @@ fn main() -> Result<(), iced_layershell::Error> {
order.middle.clone(),
order.right.clone(),
),
padding,
spacing,
)
},
subscription::namespace,
@@ -82,16 +77,6 @@ fn main() -> Result<(), iced_layershell::Error> {
)
.style(view::style)
.subscription(subscription::gather_subscriptions)
.settings(Settings {
layer_settings: LayerShellSettings {
size: Some((0, BAR_HEIGHT)),
exclusive_zone: BAR_HEIGHT as i32,
anchor: Anchor::Top | Anchor::Left | Anchor::Right,
start_mode,
keyboard_interactivity: iced_layershell::reexport::KeyboardInteractivity::None,
..Default::default()
},
..Default::default()
})
.settings(settings)
.run()
}
+4 -4
View File
@@ -34,7 +34,7 @@ fn bar_view(bar: &Bar) -> Element<'_, Message> {
.map(|w| Message::Event(Msg::Wire(w)))
})
.collect::<Vec<Element<Message>>>())
.spacing(8)
.spacing(bar.spacing)
.align_y(Alignment::Center);
let middle = row(bar
@@ -49,7 +49,7 @@ fn bar_view(bar: &Bar) -> Element<'_, Message> {
.map(|w| Message::Event(Msg::Wire(w)))
})
.collect::<Vec<Element<Message>>>())
.spacing(8)
.spacing(bar.spacing)
.align_y(Alignment::Center);
let right = row(bar
.order
@@ -63,7 +63,7 @@ fn bar_view(bar: &Bar) -> Element<'_, Message> {
.map(|w| Message::Event(Msg::Wire(w)))
})
.collect::<Vec<Element<Message>>>())
.spacing(8)
.spacing(bar.spacing)
.align_y(Alignment::Center);
let row = row![
@@ -77,7 +77,7 @@ fn bar_view(bar: &Bar) -> Element<'_, Message> {
.align_y(Alignment::Center);
container(row)
.padding(8)
.padding([0.0, bar.padding])
.width(Length::Fill)
.height(Length::Fill)
.align_y(Alignment::Center)