init
This commit is contained in:
+85
@@ -0,0 +1,85 @@
|
||||
//! barbar — a Wayland layer-shell status bar built on `iced` + `iced_layershell`.
|
||||
//!
|
||||
//! Renders a full-width bar pinned to the top of the screen via the
|
||||
//! `wlr-layer-shell` protocol. Optionally target a specific output by
|
||||
//! passing its name as the first CLI argument.
|
||||
|
||||
use iced::widget::{row, text};
|
||||
use iced::{Alignment, Element, Length, Task, Theme};
|
||||
use iced_layershell::application;
|
||||
use iced_layershell::reexport::Anchor;
|
||||
use iced_layershell::settings::{LayerShellSettings, StartMode, Settings};
|
||||
use iced_layershell::to_layer_message;
|
||||
|
||||
/// Height of the bar in logical pixels.
|
||||
const BAR_HEIGHT: u32 = 36;
|
||||
|
||||
/// Optional width of the bar; `None` means "as wide as the output".
|
||||
const BAR_WIDTH: Option<u32> = None;
|
||||
|
||||
pub fn main() -> Result<(), iced_layershell::Error> {
|
||||
// Target a specific output if one was given, otherwise the active one.
|
||||
let start_mode = match std::env::args().nth(1) {
|
||||
Some(output) => StartMode::TargetScreen(output),
|
||||
None => StartMode::Active,
|
||||
};
|
||||
|
||||
application(Bar::default, namespace, update, view)
|
||||
.style(style)
|
||||
.settings(Settings {
|
||||
layer_settings: LayerShellSettings {
|
||||
size: Some((BAR_WIDTH.unwrap_or(0), BAR_HEIGHT)),
|
||||
exclusive_zone: BAR_HEIGHT as i32,
|
||||
anchor: Anchor::Top | Anchor::Left | Anchor::Right,
|
||||
start_mode,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
})
|
||||
.run()
|
||||
}
|
||||
|
||||
/// Application state. Empty for now; placeholders will evolve into
|
||||
/// workspace/clock/system modules.
|
||||
#[derive(Debug, Default)]
|
||||
struct Bar;
|
||||
|
||||
/// Messages produced by user input, events and subscriptions.
|
||||
#[to_layer_message]
|
||||
#[derive(Debug, Clone)]
|
||||
enum Message {
|
||||
/// No-op used as a fallback target for pending subscriptions.
|
||||
Noop,
|
||||
}
|
||||
|
||||
fn namespace() -> String {
|
||||
String::from("barbar")
|
||||
}
|
||||
|
||||
fn update(_bar: &mut Bar, _message: Message) -> Task<Message> {
|
||||
Task::none()
|
||||
}
|
||||
|
||||
fn view(_bar: &Bar) -> Element<'_, Message> {
|
||||
row![
|
||||
text("workspaces").size(14),
|
||||
text("|").size(14),
|
||||
text("clock").size(14),
|
||||
text("|").size(14),
|
||||
text("system").size(14),
|
||||
]
|
||||
.spacing(12)
|
||||
.padding(8)
|
||||
.align_y(Alignment::Center)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill)
|
||||
.into()
|
||||
}
|
||||
|
||||
fn style(_bar: &Bar, theme: &Theme) -> iced::theme::Style {
|
||||
use iced::theme::Style;
|
||||
Style {
|
||||
background_color: theme.palette().background,
|
||||
text_color: theme.palette().text,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user