Rename config files

Switch to file-as-struct for the ones that are just the configs structs
and use singular for the ones that are just parsers
This commit is contained in:
Ben Buhse 2026-02-17 12:53:15 -06:00
commit b4c4019cad
No known key found for this signature in database
GPG key ID: 7916ACFCD38FD0B4
7 changed files with 131 additions and 135 deletions

View file

@ -39,17 +39,13 @@ bar_config: ?BarConfig = null,
/// Tag bind entries parsed from config (tag_bind nodes in keybinds block) /// Tag bind entries parsed from config (tag_bind nodes in keybinds block)
tag_binds: std.ArrayList(Keybind) = .{}, tag_binds: std.ArrayList(Keybind) = .{},
// We use a hash map so that duplicate keybinds can be easily de-duplicated // We use a hash map so that duplicate keybinds can be easily de-duplicated
keybinds: keybind_helper.Map = .{}, keybinds: keybind.Map = .{},
pointer_binds: std.ArrayList(PointerBind) = .{}, pointer_binds: std.ArrayList(PointerBind) = .{},
input_configs: std.ArrayList(InputConfig) = .{}, input_configs: std.ArrayList(InputConfig) = .{},
// Re-exports // Re-exports
pub const Keybind = keybind_helper.Keybind; pub const Keybind = keybind.Keybind;
pub const PointerBind = pointer_bind_helper.PointerBind; pub const PointerBind = pointer_bind.PointerBind;
pub const BarConfig = bar_helper.BarConfig;
pub const TagOverlayConfig = tag_overlay_helper.TagOverlayConfig;
pub const InputConfig = input_helper.InputConfig;
pub const AttachMode = enum { pub const AttachMode = enum {
top, top,
@ -268,15 +264,15 @@ fn load(config: *Config, reader: *Io.Reader) !void {
.child_block_begin => { .child_block_begin => {
if (next_child_block) |child_block| { if (next_child_block) |child_block| {
switch (child_block) { switch (child_block) {
.bar => try bar_helper.load(config, &parser, hostname), .bar => try BarConfig.load(config, &parser, hostname),
.borders => try borders_helper.load(config, &parser, hostname), .borders => try border.load(config, &parser, hostname),
.keybinds => try keybind_helper.load(config, &parser, hostname), .keybinds => try keybind.load(config, &parser, hostname),
.pointer_binds => try pointer_bind_helper.load(config, &parser, hostname), .pointer_binds => try pointer_bind.load(config, &parser, hostname),
.input => { .input => {
try input_helper.load(config, &parser, pending_input_name, hostname); try InputConfig.load(config, &parser, pending_input_name, hostname);
pending_input_name = null; // ownership transferred pending_input_name = null; // ownership transferred
}, },
.tag_overlay => try tag_overlay_helper.load(config, &parser, hostname), .tag_overlay => try TagOverlayConfig.load(config, &parser, hostname),
else => { else => {
// Nothing else should ever be marked as a next_child_block // Nothing else should ever be marked as a next_child_block
unreachable; unreachable;
@ -322,13 +318,13 @@ const utils = @import("utils.zig");
const RiverColor = utils.RiverColor; const RiverColor = utils.RiverColor;
const XkbBindings = @import("XkbBindings.zig"); const XkbBindings = @import("XkbBindings.zig");
const bar_helper = @import("config/bar.zig"); const border = @import("config/border.zig");
const borders_helper = @import("config/borders.zig");
const input_helper = @import("config/input.zig");
const keybind_helper = @import("config/keybinds.zig");
const pointer_bind_helper = @import("config/pointer_binds.zig");
const tag_overlay_helper = @import("config/tag_overlay.zig");
const helpers = @import("config/helpers.zig"); const helpers = @import("config/helpers.zig");
const keybind = @import("config/keybind.zig");
const pointer_bind = @import("config/pointer_bind.zig");
const BarConfig = @import("config/BarConfig.zig");
const InputConfig = @import("config/InputConfig.zig");
const TagOverlayConfig = @import("config/TagOverlayConfig.zig");
const log = std.log.scoped(.Config); const log = std.log.scoped(.Config);

View file

@ -2,16 +2,17 @@
// //
// SPDX-License-Identifier: GPL-3.0-only // SPDX-License-Identifier: GPL-3.0-only
pub const NodeName = enum { const BarConfig = @This();
const NodeName = enum {
fonts, fonts,
text_color, text_color,
background_color, background_color,
position, position,
margins, margins,
}; };
pub const MarginsNodeName = enum { top, right, bottom, left }; const MarginsNodeName = enum { top, right, bottom, left };
pub const BarConfig = struct {
// Comma separated list of FontConfig formatted font specifications. // Comma separated list of FontConfig formatted font specifications.
// null means use the default ("monospace:size=14"). // null means use the default ("monospace:size=14").
fonts: ?[]const u8 = null, fonts: ?[]const u8 = null,
@ -39,7 +40,6 @@ pub const BarConfig = struct {
}, },
}; };
} }
};
pub fn load(config: *Config, parser: *kdl.Parser, hostname: ?[]const u8) !void { pub fn load(config: *Config, parser: *kdl.Parser, hostname: ?[]const u8) !void {
config.bar_config = .{}; // Presence of block = enabled; initialize with defaults config.bar_config = .{}; // Presence of block = enabled; initialize with defaults

View file

@ -2,7 +2,30 @@
// //
// SPDX-License-Identifier: GPL-3.0-only // SPDX-License-Identifier: GPL-3.0-only
pub const InputConfig = struct { const InputConfig = @This();
const NodeName = enum {
send_events,
tap,
tap_button_map,
drag,
drag_lock,
three_finger_drag,
accel_profile,
accel_speed,
natural_scroll,
left_handed,
click_method,
clickfinger_button_map,
middle_emulation,
scroll_method,
scroll_button,
scroll_button_lock,
dwt,
dwtp,
rotation,
};
/// Device name to match /// Device name to match
/// If this is null, applies to all devices /// If this is null, applies to all devices
name: ?[]const u8 = null, name: ?[]const u8 = null,
@ -26,29 +49,6 @@ pub const InputConfig = struct {
dwt: ?DwtState = null, dwt: ?DwtState = null,
dwtp: ?DwtpState = null, dwtp: ?DwtpState = null,
rotation: ?u32 = null, rotation: ?u32 = null,
};
const NodeName = enum {
send_events,
tap,
tap_button_map,
drag,
drag_lock,
three_finger_drag,
accel_profile,
accel_speed,
natural_scroll,
left_handed,
click_method,
clickfinger_button_map,
middle_emulation,
scroll_method,
scroll_button,
scroll_button_lock,
dwt,
dwtp,
rotation,
};
pub fn load(config: *Config, parser: *kdl.Parser, name: ?[]const u8, hostname: ?[]const u8) !void { pub fn load(config: *Config, parser: *kdl.Parser, name: ?[]const u8, hostname: ?[]const u8) !void {
var input_config: InputConfig = .{ .name = name }; var input_config: InputConfig = .{ .name = name };

View file

@ -2,7 +2,9 @@
// //
// SPDX-License-Identifier: GPL-3.0-only // SPDX-License-Identifier: GPL-3.0-only
pub const NodeName = enum { const TagOverlayConfig = @This();
const NodeName = enum {
border_width, border_width,
tag_amount, tag_amount,
tags_per_row, tags_per_row,
@ -23,10 +25,9 @@ pub const NodeName = enum {
margins, margins,
}; };
pub const AnchorsNodeName = enum { top, right, bottom, left }; const AnchorsNodeName = enum { top, right, bottom, left };
pub const MarginsNodeName = enum { top, right, bottom, left }; const MarginsNodeName = enum { top, right, bottom, left };
pub const TagOverlayConfig = struct {
border_width: u8 = 2, border_width: u8 = 2,
tag_amount: u8 = 9, tag_amount: u8 = 9,
tags_per_row: u8 = 32, tags_per_row: u8 = 32,
@ -84,7 +85,6 @@ pub const TagOverlayConfig = struct {
.timeout = config.timeout, .timeout = config.timeout,
}; };
} }
};
pub fn load(config: *Config, parser: *kdl.Parser, hostname: ?[]const u8) !void { pub fn load(config: *Config, parser: *kdl.Parser, hostname: ?[]const u8) !void {
config.tag_overlay_config = .{}; // Presence of block = enabled; initialize with defaults config.tag_overlay_config = .{}; // Presence of block = enabled; initialize with defaults