#xorg #x11 #panel #bar #dock

leechbar

A library for building your own bar on top of XCB

12 releases

Uses old Rust 2015

0.5.4 Sep 3, 2018
0.5.3 Nov 21, 2017
0.4.2 Nov 18, 2017
0.3.0 Oct 31, 2017
0.1.0 Oct 14, 2017

#15 in #text-alignment

Download history 4/week @ 2023-11-06 7/week @ 2023-11-13 30/week @ 2023-11-20 42/week @ 2023-11-27 15/week @ 2023-12-04 16/week @ 2023-12-11 6/week @ 2023-12-18 28/week @ 2023-12-25 2/week @ 2024-01-01 5/week @ 2024-01-08 3/week @ 2024-01-15 15/week @ 2024-01-22 27/week @ 2024-01-29 4/week @ 2024-02-05 44/week @ 2024-02-12 247/week @ 2024-02-19

322 downloads per month

MIT/Apache

81KB
1.5K SLoC

[DEPRECATED]

This project never reached a usable state and is not developed anymore.


lib.rs:

Leechbar is a crate for creating your own bar/panel/dock.

The goal of leechbar is to provide a library that allows creating a completely custom bar. The purpose is not simplicity. So if you don't plan on using more than just simple text, you might want to look at something like lemonbar instead.

Usage

This crate can be installed through crates.io and can be used by adding it to your Cargo.toml.

[dependencies]
leechbar = "0.2.1"

Examples

These snippets just touch the basics of using leechbar, for more complete examples you can take a look at the github repository.

The first thing that needs to be done for using leechbar, is setting up the bar configuration itself. This is done using the BarBuilder struct.

use leechbar::{BarBuilder, Color};

// All method calls that take parameters are optional
BarBuilder::new()
    .background_color(Color::new(255, 0, 255, 255))
    .font("Fira Mono Medium 14")
    .output("DVI-1")
    .height(30)
    .spawn()
    .unwrap();

After creating a configuration using BarBuilder, you have to add your components to the bar. This is a little more complicated, because you need to implement the Component trait.

use leechbar::{Bar, BarBuilder, Component, Text, Foreground};

struct MyComponent {
    bar: Bar,
}

// You can define your own custom components like this
impl Component for MyComponent {
    // Print "Hello, World!" as text
    fn foreground(&self) -> Foreground {
        Text::new(&self.bar, "Hello, World", None, None).unwrap().into()
    }
}

// Create a new bar
let mut bar = BarBuilder::new().spawn().unwrap();

// Create an instance of the component
let comp = MyComponent { bar: bar.clone() };

// Add an instance of your component to your bar
bar.add(comp);

// Start the event loop that handles all X events
bar.start_event_loop();

Logging

This crate supports log, if you want to enable this logging, you can add env_logger to your binary.

extern crate env_logger;

fn main() {
    env_logger::init();
    // All the cool bar stuff
}

Dependencies

~18MB
~193K SLoC