[][src]Crate 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 {
        let _ = 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!("");
}

Modules

config

Bar configuration state.

event

Data models used for sending events to the config.

Structs

Bar

Wrapper around the bar configuration.

Functions

config_file

Find the configuration file.