Crate lazybar_core

source ·
Expand description

This is a lightweight, event-driven status bar for EWMH-compliant window managers on X11.

It uses tokio in combination with existing event APIs to poll as rarely as possible. For example, the Inotify panel uses Linux’s inotify to monitor the contents of a file.

You’re welcome to use this crate as a library if you want to expand on the functionality included herein, but its intentended use case is as a binary. It reads a configuration file located at $XDG_CONFIG_HOME/lazybar/config.toml, and this documentation will focus on accepted syntax for that file.

The general structure of the file is as follows:

Top-level tables:

  • bars: each subtable defines a bar, and the name is used as a command line argument to run that bar.
  • ramps: each subtable defines a ramp with the same name, and those names are referenced by panel tables (see below).
  • panels: each subtable defines a panel with the same name, and those names are referenced by bar tables.

None of these tables need to be declared explicitly, as they hold no values of their own. [bars.example] is sufficient to define a bar named example. Any values in these top level tables will be ignored, along with any top level table with a different name. See https://toml.io/ for more information.

Note: types are pretty flexible, and config will try its best to figure out what you mean, but if you have issues, make sure that your types are correct.

§Example Config

[bars.example]
position = "top"
height = 36
transparent = true
bg = "#0000"
default_bg = "#0000"
default_fg = "#ccc"
default_font = "FiraMono Nerd Font Mono 10"
margin_left = 10
margin_internal = 10
margin_right = 10
panels_left = ["xwindow"]
panels_center = ["clock"]
panels_right = ["pulseaudio","separator","network","separator","battery"]

[panels.xwindow]
type = "xwindow"

[panels.pulseaudio]
type = "pulseaudio"
ramp = "pa"
muted_ramp = "pa_muted"

[panels.network]
type = "network"
if_name = "wlan0"
# if_name = "eth0"
format_connected = "<span foreground='#0ff'>%ifname%</span> %essid% %local_ip%"
format_disconnected = "<span foreground='#0ff'>%ifname%</span> <span foreground='#888'>disconnected</span>"

[panels.mpd]
type = "mpd"
progress_bar = true
max_width = 300
strategy = "scroll"
scroll_interval = 300

[panels.battery]
type = "battery"

[panels.clock]
type = "clock"
precision = "seconds"
formats = ["<span foreground='#0ff'>%Y-%m-%d %T</span>", "<span foreground='#f00'>%Y-%m-%d %T</span>"]
click-left = "cycle"

[panels.separator]
type = "separator"
format = "<span font='FiraMono Nerd Font Mono 13' foreground='#666'>  //  </span>"

[ramps.pa]
0 = "<span font_size='25pt' rise='-7.5pt'>󰕿</span> "
1 = "<span font_size='25pt' rise='-7.5pt'>󰖀</span> "
2 = "<span font_size='25pt' rise='-7.5pt'>󰕾</span> "

[ramps.pa_muted]
0 = "<span font_size='25pt' rise='-7.5pt'>󰸈</span> "
1 = "<span font_size='25pt' rise='-7.5pt'>󰖁</span> "

Re-exports§

Modules§

  • The bar itself and bar-related utility structs and functions.
  • Builder structs for non-panel items, courtesy of derive_builder. See panels::builders for panel builders.
  • Support for inter-process communication, like that provided by the lazybar-msg crate.
  • Panels that can be added to the bar. A new panel must implement PanelConfig.
  • The parser for the config.toml file.

Structs§

Enums§

Traits§

  • The trait implemented by all panels. Provides support for parsing a panel and turning it into a PanelStream.

Functions§

  • The end of a typical draw function. Takes a cairo context, a string to display, and attributes to use, and returns a closure that will do the drawing and a tuple representing the final width and height.
  • Removes a value from a given config table and returns an attempt at parsing it into a table
  • Removes a value from a given config table and returns an attempt at parsing it into an array
  • Removes a value from a given config table and returns an attempt at parsing it into a bool
  • Removes a value from a given config table and returns an attempt at parsing it into a color
  • Removes a value from a given config table and returns an attempt at parsing it into a float
  • Removes a value from a given config table and returns an attempt at parsing it into a string
  • Removes a value from a given config table and returns an attempt at parsing it into a uint

Type Aliases§

  • A function that can be called repeatedly to draw the panel.
  • A stream that produces panel changes when the underlying data source changes.