Implement initial config loading

Config goes in $XDG_CONFIG_HOME/beansprout/config.kdl or
$HOME/.config/beansprout/config.kdl

Config is in the kdl format. Right now, the supported options are

```zig
/// Width of window borders in pixels
border_width: u8 = 2,
/// Color of focused window's border in 0xRRGGBBAA or 0xRRGGBB form
border_color_focused: RiverColor = utils.parseRgbaComptime("0x89b4fa"),
/// Color of uffocused windows' borders in 0xRRGGBBAA or 0xRRGGBB form
border_color_unfocused: RiverColor = utils.parseRgbaComptime("0x1e1e2e"),

/// Where a new window should attach, top or bottom of the stack
attach_mode: AttachMode = .top,
/// Should focus change when the cursor moves onto a new window
focus_follows_pointer: bool = true,
/// Should the pointer warp to the center of newly-focused windows
pointer_warp_on_focus_change: bool = true,
```

I plan to add Keybinds shortly. If parsing the configuration fails,
the default config will be used and the WM will continue loading.
This commit is contained in:
Ben Buhse 2026-01-27 14:54:27 -06:00
commit 43e3d268c9
No known key found for this signature in database
GPG key ID: 7916ACFCD38FD0B4
8 changed files with 261 additions and 18 deletions

View file

@ -12,8 +12,12 @@ pub fn build(b: *std.Build) void {
const strip = b.option(bool, "strip", "Omit debug information") orelse false;
const pie = b.option(bool, "pie", "Build a Position Independent Executable") orelse false;
// Wayland
const scanner = Scanner.create(b, .{});
const wayland = b.createModule(.{ .root_source_file = scanner.result });
// Rest of the deps
const kdl = b.dependency("kdl", .{}).module("kdl");
const known_folders = b.dependency("known_folders", .{}).module("known-folders");
const xkbcommon = b.dependency("xkbcommon", .{}).module("xkbcommon");
scanner.addCustomProtocol(b.path("protocol/river-window-management-v1.xml"));
@ -36,8 +40,11 @@ pub fn build(b: *std.Build) void {
});
exe.pie = pie;
// Make sure to also add new imports to the exe_check step
exe.root_module.addImport("wayland", wayland);
exe.root_module.addImport("xkbcommon", xkbcommon);
exe.root_module.addImport("kdl", kdl);
exe.root_module.addImport("known_folders", known_folders);
exe.linkLibC();
exe.linkSystemLibrary("wayland-client");
@ -82,6 +89,9 @@ pub fn build(b: *std.Build) void {
});
exe_check.root_module.addImport("wayland", wayland);
exe_check.root_module.addImport("xkbcommon", xkbcommon);
exe_check.root_module.addImport("kdl", kdl);
exe_check.root_module.addImport("known_folders", known_folders);
exe_check.linkLibC();
exe_check.linkSystemLibrary("wayland-client");