Crate redblocks[][src]

Expand description

About

Redblocks is a library inspired by xmobar for creating your own status blocks that writes to XROOTNAME?. Primaraly intended for along side the Penrose library.

Requirments

Using redblock is intended to be simple, baring creating custom modules; if this is not the case I would consider that a bug and would engorage you to raise the issue as such.

The one caviate to the aformentioned principle is a basic understanding of rust is required to setup and configure your statusbar. You can paruse the reference for any concepts you don’t understand (baring anyghing specific to redblocks). For a more compleate introduction to the language I would encorage you to check out The Book. a great place to start learing is here; if you need help installing Rust please see the installation guide.

Setup

To use redblocks add the following to your Cargo.toml.

[dependencies]
redblocks = 0.1.2
``
# Building your own widgets
Currently doing anything at all with [redblocks] requires you to creat your own custom plugins.

First you will need to create a struct to hold the information you wish displayed in the status blocks. When implementing the plugin's new() function it is importatn that it return itself in a [`Box`]. Once you have created your status plugin you will need to implement both the [`std::fmt::Display`] and [Update] traits; the implementation of which can be found below.
[Update]: crate::Update

 # Example Widget
For the following example we are going to be creating a simple widget that couts how many seconds the status blocks have been runing.

// for creating the plugin use redblocks::Update; // for drawing the statusblocks use redblocks::{Widget, start_bar}; use std::fmt::{self,Display};

struct Counter(u64);

impl Counter { fn new() -> Box { Box::new(Self(0)) } }

impl Display for Counter { fn fmt(&self, f: &mut fmt::Formatter<’_>) -> fmt::Result { write!(f, “{}”, self.0) } }

impl Update for Counter { fn refresh(&mut self) { self.0 = self.0 + 1; } }

fn main() { // set the update intervel in seconds let update_intervel = 1;

// create create the plugin 
let counter_plugin = Counter::new();

// create the widget
let counter_widget = Widget::new(counter_plugin, update_intervel);

// start_bar is a macro so it can accept more than one argument
start_bar!(counter_widget);

}

Macros

Structs

Holds StatusBar

Handles timing and updating

Traits

Type Definitions

constructed by the start_bar macro