weir

package module
v0.0.0-...-0d112a8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2026 License: MIT Imports: 0 Imported by: 0

README

weir

A window manager for river 0.4+, written in Go. xmonad-style dynamic tiling, fully programmatic configuration over a unix socket, first-class multi-output support.

A weir is a small dam that controls a river's flow.

Status: early development, but functional. Tiling, workspaces, multi-output, key/pointer bindings, and the control socket all work against river 0.4.5. See PLAN.md for the design and roadmap, and example/init for a complete xmonad-flavored configuration.

go install github.com/psanford/weir/cmd/weir@latest
go install github.com/psanford/weir/cmd/weirctl@latest
cp example/init ~/.config/river/init && chmod +x ~/.config/river/init
river

Layout

Path What
core/ The window-management state machine: model, layouts, commands. Pure Go, no Wayland imports, fully unit-tested.
bridge/ The river protocol adapter: owns the manage/render sequence loop and translates between protocol events and the core model. Tested against a fake compositor that enforces the protocol's sequencing rules.
ipc/ The control socket: newline-delimited JSON over a unix socket. Commands, queries, and a state-change subscription stream for bars.
cmd/weir/ The window manager binary. Start it from river's init script.
cmd/weirctl/ The CLI: weirctl focus next, weirctl get state, weirctl subscribe, weirctl help.
wire/ Pure-Go Wayland client wire protocol: connection, marshalling, fd passing, object lifetime, and the hand-written wl_display/wl_registry/wl_callback bootstrap. No cgo.
wire/wiretest/ A fake compositor speaking the raw wire format over a socketpair, for testing protocol code without river.
protocol/ Vendored protocol XML (wayland core + river's six extensions).
protocols/wl/, protocols/river/ Generated typed bindings. Regenerate with go generate ./....
internal/gen/ The protocol code generator.
cmd/wmsim/ ASCII simulator: replay a script of events and commands against the core and render the resulting layout.
example/ wmsim scenario scripts.

Developing

go test ./...          # unit + property + protocol tests, no compositor needed
go run ./cmd/wmsim example/two-outputs.txt
go run ./cmd/wmsim     # interactive REPL ("help" for syntax)

The property tests in core/invariants_test.go drive the model with tens of thousands of random operations and check the structural invariants from PLAN.md after every step. If you change the model, that suite is the first thing to trust. The bridge tests in bridge/ run against a fake compositor that fails the test if a request is ever sent in an illegal protocol phase.

Against a real river

scripts/integration-test.sh runs weir inside a real headless river (wlroots headless backend + pixman renderer — no GPU, no display, no seat), opens terminals, drives weir with weirctl, and asserts on the JSON state it reports. scripts/smoke-test.sh is a faster log-based check and scripts/screenshot-test.sh captures a PNG of the tiled layout via grim.

eval "$(scripts/fetch-river.sh)"   # sets $RIVER and $FOOT from the nix cache
scripts/smoke-test.sh

Or run it nested in your current desktop session to interact with it:

go build ./cmd/weir && river -c ./weir

License

MIT. The protocol definitions vendored under protocol/ carry their own permissive licenses in their embedded <copyright> blocks (wayland.xml from the Wayland project, river-*.xml from river).

Documentation

Overview

Package weir is the repository root; see PLAN.md for the layout.

The directives below regenerate the protocol bindings from the vendored XML in protocol/. Run "go generate ./..." after changing the generator or updating a protocol file.

Directories

Path Synopsis
Package bridge connects the pure window-management core to a river compositor over the river-window-management-v1 protocol.
Package bridge connects the pure window-management core to a river compositor over the river-window-management-v1 protocol.
cmd
weir command
Command weir is a window manager for the river Wayland compositor.
Command weir is a window manager for the river Wayland compositor.
weirctl command
Command weirctl controls a running weir window manager over its unix control socket.
Command weirctl controls a running weir window manager over its unix control socket.
wmsim command
Command wmsim drives the weir core model with a script of events and commands and renders the resulting window arrangement as ASCII art.
Command wmsim drives the weir core model with a script of events and commands and renders the resulting window arrangement as ASCII art.
internal
gen command
Command gen generates Go bindings for Wayland protocols from their XML descriptions.
Command gen generates Go bindings for Wayland protocols from their XML descriptions.
Package ipc implements weir's control socket: a unix socket speaking newline-delimited JSON over which every weir command can be executed, state can be queried, and state changes can be subscribed to.
Package ipc implements weir's control socket: a unix socket speaking newline-delimited JSON over which every weir command can be executed, state can be queried, and state changes can be subscribed to.
protocols
wl
Package wire implements the client side of the Wayland wire protocol: connection management, message marshalling, file descriptor passing, and object lifetime.
Package wire implements the client side of the Wayland wire protocol: connection management, message marshalling, file descriptor passing, and object lifetime.
wiretest
Package wiretest provides a fake Wayland compositor for testing clients of the wire package and generated protocol bindings without a real compositor.
Package wiretest provides a fake Wayland compositor for testing clients of the wire package and generated protocol bindings without a real compositor.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL