[][src]Struct cnx::widgets::Battery

pub struct Battery { /* fields omitted */ }

Shows battery charge percentage and (dis)charge time.

This widget shows the battery's current charge percentage and the amount of remaining (dis)charge time, depending on whether the battery is charging or discharging. The format of the output is (PP% HH:MM).

When the battery has less than 10% charge remaining, the widget's text will change to the specified warning_color.

Battery charge information is read from /sys/class/power_supply/BAT0/.

Methods

impl Battery[src]

pub fn new(cnx: &Cnx, attr: Attributes, warning_color: Color) -> Battery[src]

Creates a new Battery widget.

Creates a new Battery widget, whose text will be displayed with the given Attributes. The caller can provide use the warning_color argument, to control the Color of the text once the battery has less than 10% charge remaining.

The Cnx instance is borrowed during construction in order to get access to handles of its event loop. However, it is not borrowed for the lifetime of the widget. See the cnx_add_widget!() for more discussion about the lifetime of the borrow.

Examples

let attr = Attributes {
    font: Font::new("SourceCodePro 21"),
    fg_color: Color::white(),
    bg_color: None,
    padding: Padding::new(8.0, 8.0, 0.0, 0.0),
};

let mut cnx = Cnx::new(Position::Top)?;
cnx_add_widget!(cnx, Battery::new(&cnx, attr.clone(), Color::red()));

Trait Implementations

Auto Trait Implementations

impl !Send for Battery

impl !Sync for Battery

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Erased for T