Bar Config
Crate for easily creating system bars/panels/docks.
The goal of this crate is to make it as simple as possible to create complex bars/panels/docks for linux without having to worry about anything but rendering.
To get started with the crate, a new bar needs to be created. This is done using the load
method in the Bar
. Once this is acquired the recv
, try_recv
and lock
methods
should be all that is required to receive events and render the bar.
Examples
use std::io::Cursor;
use bar_config::Bar;
fn main() {
let input = Cursor::new(String::from(
"\
height: 30\n\
monitors:\n\
- { name: \"DVI-1\" }\n\
left:\n\
- { text: \"Hello, World!\" }\n\
center:\n\
- { name: \"clock\" }\n\
right:\n\
- { text: \"VOLUME\" }",
));
let mut bar = Bar::load(input).unwrap();
print_bar(&bar);
loop {
if let Ok(_) = bar.recv() {
print_bar(&bar);
}
}
}
fn print_bar(bar: &Bar) {
let config = bar.lock();
for comp in config
.left
.iter()
.chain(&config.center)
.chain(&config.right)
{
if let Some(text) = comp.text() {
print!("{}\t", text);
}
}
println!("");
}
Bar Configuration Grammar
This is the grammar for the user configuration. It is designed to map to data formats like YAML or JSON but should also allow an easy representation in Rust.
# Legend
# ! Field is required
# ? Field is optional
# Root element of the bar
# General configuration options
!
!
# Default fallback values for components
# Component containers
# A single component/block/module in the bar
# Name used to identify which component should be loaded
# Text which will be displayed inside the component
# Options available for every component
# Extra options are passed to the component
# Default options available for every component
)
# Background of a component or the bar
! ) | )
# Dinstinct identification for a font
!
!
# Distinct identification for a monitor
!
# Border separating the bar from the rest of the WM
!
! )
# Available positions for the bar
! |