Development
Development
Prerequisites
- Go 1.22 or later
- wlroots 0.20
- wayland 1.24+
- libxkbcommon
- NixOS (recommended) or equivalent Linux system
Getting Started
NixOS
Enter the development shell:
nix-shellBuilding
make buildThe binary is output to build/samwm.
Running
./build/samwmOr with a specific config:
./build/samwm -config /path/to/config.luaRunning Tests
make testProject Structure
cmd/samwm/— Entry pointinternal/compositor/— Core compositor logic and keybinding handlinginternal/window/— Window type and managementinternal/layout/— Tiling layout algorithmsinternal/config/— Configuration loadingpkg/wlroots/— CGo bindings for wlroots-0.20pkg/lua/— Lua scripting VM
Adding Features
Adding a New Layout
- Create a new file in
internal/layout/ - Implement the
Layoutinterface:
type Layout interface {
Name() string
Apply(windows []*window.Window, bounds window.Rect, cfg config.Config)
}- Register in
layout/manager.goNewManager()
Adding a New Keybinding Action
- Add a case in
internal/compositor/keybind.goexecuteAction() - Implement the action method
- Add the keybinding to the default config in
internal/config/config.go
Adding New wlroots Bindings
- Add CGo bindings in
pkg/wlroots/ - Use
ListenerManagerfor wayland signal callbacks - Add C helper functions for union field access if needed
Debugging
Common Issues
- SIGABRT: renderer != NULL: Ensure
wlr_output_init_renderis called beforewlr_output_layout_add_auto. - Undefined symbol errors: Ensure all CGo files have the same
#cgo pkg-configflags. - Thread issues: All wlroots operations must happen on the same locked OS thread.
Verbose Logging
./build/samwm -vChecking wlroots Headers
ls /nix/store/*-wlroots-0.20.0/include/wlroots-0.20/wlr/types/Build Targets
make build— Build the binarymake test— Run testsmake clean— Remove build artifactsmake fmt— Format Go codemake vet— Run go vet