Module redblocks::plugins[][src]

Expand description

Library provided plugins

Building your own 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.

Example Plugin

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


use redblocks::Update;

use std::fmt::{self, Display};

struct Counter(u64);

impl Counter {

    fn new() -> Box<Self> {
        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;
    }
}

Modules

strftime/strptime-inspired date and time formatting syntax.

Structs

Battery Monitor

Cpu Monitor

Prints Ram usage

Displays the current time.