Jump to content

mybar

From Hugo's wiki

mybar is a small Wayland status bar: one bar at the bottom of every monitor, configured in Lua, with modules that are plugins.

mybar

  • Any wlroots compositor: it uses wlr-layer-shell, so Hyprland, sway and river all work.
  • Reloads by itself when you save the config. A config with a Lua error or a font that won't load is ignored, and the bar keeps the old one.
  • Plugins: every module is one .c file, built into a .so.
  • Event driven: most modules wait for the kernel or Hyprland to tell them something changed; the rest (cpu, disk...) read a file every few seconds.

Modules

Kind Modules
Hyprland workspaces (with app icons), window, submap, language
sway sway_workspaces, sway_window, sway_mode, sway_language
Hardware battery, brightness, volume, capslock
System system (cpu, memory, temperature), disk
Network network, vpn
Other media (anything playing, through playerctl), datetime

The sway modules take the same options as the Hyprland ones. Modules with nothing to show, like vpn with no VPN up, take no space.

Installation

It needs wayland, wayland-protocols, fcft, pixman and LuaJIT (Lua 5.1 works too, with make LUA_PKG=lua5.1). The second line is optional: app icons in the workspaces (librsvg, cairo), media (playerctl) and volume (pactl).

# pacman -S --needed base-devel wayland wayland-protocols fcft pixman luajit
# pacman -S --needed librsvg cairo playerctl libpulse
$ git clone https://github.com/hugoocoto/mybar
$ cd mybar
$ make
# make install

make install installs to /usr/local; make run runs it in place. The README has the package names for Debian and Fedora too.

It is also available through the pm user repository, which also installs the modules into ~/.local/lib/mybar/modules.

Configuration

mybar reads ~/.config/mybar/config.lua, then ./config.lua, or the file given with -c. Anything left out takes its default:

Config = {
    height = 26,
    font   = "Iosevka NFP:pixelsize=18",
    bg     = "#141617",
    fg     = "#d4be98",
    modules = {
        left   = { "workspaces", "window" },
        center = {},
        right  = {
            "media",
            "system",
            { path = "battery", low = 20 },
            "datetime",
        },
    },
}

Every module takes path, interval, color and spacing; the rest of its options are documented at the top of modules/NAME.c, and the config.lua in the repository lists every module with all of them. pkill -USR1 mybar forces a reload.

Writing a module

Drop a .c file in modules/ and run make: it becomes modules/NAME.so, and "NAME" goes in the config. The interface is src/plugin.h. Start from modules/datetime.c for a plain text module, or modules/workspaces.h for one that draws itself.

See also