2hdddg / zenway

WIP sway bar alternative that is not really a bar but an overlay displayed on top of workspaces
21 stars 1 forks source link
linux-desktop status-bar swaybar swaywm wayland

zenway

WIP sway bar alternative that is not really a bar but an overlay displayed on top of workspaces. The overlay is visible when Sway mod key is held down.

Screenshot shows Neovim and Firefox in background with zenway status shown above it.

Alt text

Features

Installation

In Sway config add entry to start Zenway:

exec zenway

In Sway config bar config:

bar {
  mode hide
  modifier Mod1
  swaybar_command whatever
}

Configuration

Location

Searches for configuration file in:

Format

config.lua should return a Lua table that contains the static part configuration properties:

return {
    panels = {
        {
            anchor = "left"
            widgets = {
                { sources = {'time', 'date'}, on_render = render_time },
                { sources = {'keyboard'}, on_render = render_keyboard, on_click = click_keyboard, on_wheel = wheel_keyboard },
            },
            direction = "column",
        },
        {
            anchor = "right"
            ...
        },
}

The above configuratuion will display a panel with two widgets on the left side of the screen. When zenway determines that any of the specified sources is dirty like timer expired in case of 'time' or keyboard layout changed in case of 'keyboard' the specified on_render Lua function is invoked. Zenway maintains state of all sources and makes that state accesible from Lua.

This is how the keyboard render function might look like:

local function render_keyboard()
    -- State of sources are kept in zen.<source>.<prop>
    local layout = zen.keyboard.layout
    -- Pango markup
    local markup = "<span size='20pt' color='#909090'>" .. layout .. "</span>"
    -- Simplified layout rendered by Zenway
    return {
        type = "box",
        markup = markup,
        color = "#1c1b19",
        radius = 5,
        border = { width = 2, color = '#10101080' },
        tag = "id",
    }
end

The widgets will be rendered with time aligned to the left with the keyboard rendered below as specified by the direction = "column".

The keyboard widget also specifies two other Lua functions in on_click and on_wheel. Those are invoked when user mouse clicks or wheels on widget. The render function specifies a tag, if the user clicks in that part of the widget, the tag will be the first argument to the event handler.

How to build

Build with Docker

See docker container matching your platform to build locally. The docker containers have two purposes. One, build on pull requests and two, build locally for different platforms.

Docker based build scripts for different distributions are in project root. Each build script outputs to a corresponding build directory where the binary can be found. Runtime dependencies on host needs to be installed manually.

Supported distributions:

Build on host

These packages are needed to build locally (exact name and version might vary):

To build you need gcc, pkg-config, meson and ninja

In repo root: meson build, ninja -C build

Binary and config is currently not installed so invoke the binary from the build directory. Copy the config folder to ~/.config/zenway/