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. See panels for panel-specific information.

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.
  • attrs: each subtable defines a set of attributes that can be referenced by panels.
  • bgs: each subtable defines a background configuration (shape, color) that can be referenced by attrs.

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 = "FiraCode Nerd Font 10"
margin_left = 10
margin_internal = 10
margin_right = 10
panels_left = ["xwindow"]
panels_center = ["clock"]
panels_right = ["pulseaudio","first_separator","network","separator","battery"]
ipc = true

[panels.xwindow]
type = "xwindow"

[panels.pulseaudio]
type = "pulseaudio"
ramp = "pa"
ramp_muted = "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 = 30
strategy = "scroll"
scroll_interval = 1000

[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='FiraCode Nerd Font Mono 13' foreground='#666'>  //  </span>"
dependence = "right"

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

[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§

  • Configuration options for colors and fonts.
  • Background configuration options.
  • 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§

Type Aliases§

  • A function that can be called repeatedly to draw the panel.
  • The channel endpoint associated with a panel
  • A stream that produces panel changes when the underlying data source changes.