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:
parent
03fd4d0087
commit
b4c4019cad
7 changed files with 131 additions and 135 deletions
|
|
@ -39,17 +39,13 @@ bar_config: ?BarConfig = null,
|
|||
/// Tag bind entries parsed from config (tag_bind nodes in keybinds block)
|
||||
tag_binds: std.ArrayList(Keybind) = .{},
|
||||
// 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) = .{},
|
||||
input_configs: std.ArrayList(InputConfig) = .{},
|
||||
|
||||
// Re-exports
|
||||
pub const Keybind = keybind_helper.Keybind;
|
||||
pub const PointerBind = pointer_bind_helper.PointerBind;
|
||||
|
||||
pub const BarConfig = bar_helper.BarConfig;
|
||||
pub const TagOverlayConfig = tag_overlay_helper.TagOverlayConfig;
|
||||
pub const InputConfig = input_helper.InputConfig;
|
||||
pub const Keybind = keybind.Keybind;
|
||||
pub const PointerBind = pointer_bind.PointerBind;
|
||||
|
||||
pub const AttachMode = enum {
|
||||
top,
|
||||
|
|
@ -268,15 +264,15 @@ fn load(config: *Config, reader: *Io.Reader) !void {
|
|||
.child_block_begin => {
|
||||
if (next_child_block) |child_block| {
|
||||
switch (child_block) {
|
||||
.bar => try bar_helper.load(config, &parser, hostname),
|
||||
.borders => try borders_helper.load(config, &parser, hostname),
|
||||
.keybinds => try keybind_helper.load(config, &parser, hostname),
|
||||
.pointer_binds => try pointer_bind_helper.load(config, &parser, hostname),
|
||||
.bar => try BarConfig.load(config, &parser, hostname),
|
||||
.borders => try border.load(config, &parser, hostname),
|
||||
.keybinds => try keybind.load(config, &parser, hostname),
|
||||
.pointer_binds => try pointer_bind.load(config, &parser, hostname),
|
||||
.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
|
||||
},
|
||||
.tag_overlay => try tag_overlay_helper.load(config, &parser, hostname),
|
||||
.tag_overlay => try TagOverlayConfig.load(config, &parser, hostname),
|
||||
else => {
|
||||
// Nothing else should ever be marked as a next_child_block
|
||||
unreachable;
|
||||
|
|
@ -322,13 +318,13 @@ const utils = @import("utils.zig");
|
|||
const RiverColor = utils.RiverColor;
|
||||
const XkbBindings = @import("XkbBindings.zig");
|
||||
|
||||
const bar_helper = @import("config/bar.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 border = @import("config/border.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);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,44 +2,44 @@
|
|||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
pub const NodeName = enum {
|
||||
const BarConfig = @This();
|
||||
|
||||
const NodeName = enum {
|
||||
fonts,
|
||||
text_color,
|
||||
background_color,
|
||||
position,
|
||||
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.
|
||||
// null means use the default ("monospace:size=14").
|
||||
fonts: ?[]const u8 = null,
|
||||
text_color: pixman.Color = utils.parseRgbaPixmanComptime("0xcdd6f4"),
|
||||
background_color: pixman.Color = utils.parseRgbaPixmanComptime("0x1e1e2e"),
|
||||
position: Bar.Position = .top,
|
||||
margin_top: i32 = 0,
|
||||
margin_right: i32 = 0,
|
||||
margin_bottom: i32 = 0,
|
||||
margin_left: i32 = 0,
|
||||
// TODO: Support only having the bar on specific outputs
|
||||
// output: []const u8,
|
||||
// Comma separated list of FontConfig formatted font specifications.
|
||||
// null means use the default ("monospace:size=14").
|
||||
fonts: ?[]const u8 = null,
|
||||
text_color: pixman.Color = utils.parseRgbaPixmanComptime("0xcdd6f4"),
|
||||
background_color: pixman.Color = utils.parseRgbaPixmanComptime("0x1e1e2e"),
|
||||
position: Bar.Position = .top,
|
||||
margin_top: i32 = 0,
|
||||
margin_right: i32 = 0,
|
||||
margin_bottom: i32 = 0,
|
||||
margin_left: i32 = 0,
|
||||
// TODO: Support only having the bar on specific outputs
|
||||
// output: []const u8,
|
||||
|
||||
pub fn toBarOptions(config: BarConfig) Bar.Options {
|
||||
return .{
|
||||
.fonts = config.fonts orelse "monospace:size=14",
|
||||
.text_color = config.text_color,
|
||||
.background_color = config.background_color,
|
||||
.position = config.position,
|
||||
.margins = .{
|
||||
.top = config.margin_top,
|
||||
.right = config.margin_right,
|
||||
.bottom = config.margin_bottom,
|
||||
.left = config.margin_left,
|
||||
},
|
||||
};
|
||||
}
|
||||
};
|
||||
pub fn toBarOptions(config: BarConfig) Bar.Options {
|
||||
return .{
|
||||
.fonts = config.fonts orelse "monospace:size=14",
|
||||
.text_color = config.text_color,
|
||||
.background_color = config.background_color,
|
||||
.position = config.position,
|
||||
.margins = .{
|
||||
.top = config.margin_top,
|
||||
.right = config.margin_right,
|
||||
.bottom = config.margin_bottom,
|
||||
.left = config.margin_left,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
pub fn load(config: *Config, parser: *kdl.Parser, hostname: ?[]const u8) !void {
|
||||
config.bar_config = .{}; // Presence of block = enabled; initialize with defaults
|
||||
|
|
@ -2,31 +2,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
pub const InputConfig = struct {
|
||||
/// Device name to match
|
||||
/// If this is null, applies to all devices
|
||||
name: ?[]const u8 = null,
|
||||
|
||||
send_events: ?SendEventsModes.Enum = null,
|
||||
tap: ?TapState = null,
|
||||
tap_button_map: ?TapButtonMap = null,
|
||||
drag: ?DragState = null,
|
||||
drag_lock: ?DragLockState = null,
|
||||
three_finger_drag: ?ThreeFingerDragState = null,
|
||||
accel_profile: ?AccelProfile = null,
|
||||
accel_speed: ?f64 = null,
|
||||
natural_scroll: ?NaturalScrollState = null,
|
||||
left_handed: ?LeftHandedState = null,
|
||||
click_method: ?ClickMethod = null,
|
||||
clickfinger_button_map: ?ClickfingerButtonMap = null,
|
||||
middle_emulation: ?MiddleEmulationState = null,
|
||||
scroll_method: ?ScrollMethod = null,
|
||||
scroll_button: ?u32 = null,
|
||||
scroll_button_lock: ?ScrollButtonLockState = null,
|
||||
dwt: ?DwtState = null,
|
||||
dwtp: ?DwtpState = null,
|
||||
rotation: ?u32 = null,
|
||||
};
|
||||
const InputConfig = @This();
|
||||
|
||||
const NodeName = enum {
|
||||
send_events,
|
||||
|
|
@ -50,6 +26,30 @@ const NodeName = enum {
|
|||
rotation,
|
||||
};
|
||||
|
||||
/// Device name to match
|
||||
/// If this is null, applies to all devices
|
||||
name: ?[]const u8 = null,
|
||||
|
||||
send_events: ?SendEventsModes.Enum = null,
|
||||
tap: ?TapState = null,
|
||||
tap_button_map: ?TapButtonMap = null,
|
||||
drag: ?DragState = null,
|
||||
drag_lock: ?DragLockState = null,
|
||||
three_finger_drag: ?ThreeFingerDragState = null,
|
||||
accel_profile: ?AccelProfile = null,
|
||||
accel_speed: ?f64 = null,
|
||||
natural_scroll: ?NaturalScrollState = null,
|
||||
left_handed: ?LeftHandedState = null,
|
||||
click_method: ?ClickMethod = null,
|
||||
clickfinger_button_map: ?ClickfingerButtonMap = null,
|
||||
middle_emulation: ?MiddleEmulationState = null,
|
||||
scroll_method: ?ScrollMethod = null,
|
||||
scroll_button: ?u32 = null,
|
||||
scroll_button_lock: ?ScrollButtonLockState = null,
|
||||
dwt: ?DwtState = null,
|
||||
dwtp: ?DwtpState = null,
|
||||
rotation: ?u32 = null,
|
||||
|
||||
pub fn load(config: *Config, parser: *kdl.Parser, name: ?[]const u8, hostname: ?[]const u8) !void {
|
||||
var input_config: InputConfig = .{ .name = name };
|
||||
errdefer if (input_config.name) |n| utils.gpa.free(n);
|
||||
|
|
@ -2,7 +2,9 @@
|
|||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
pub const NodeName = enum {
|
||||
const TagOverlayConfig = @This();
|
||||
|
||||
const NodeName = enum {
|
||||
border_width,
|
||||
tag_amount,
|
||||
tags_per_row,
|
||||
|
|
@ -23,68 +25,66 @@ pub const NodeName = enum {
|
|||
margins,
|
||||
};
|
||||
|
||||
pub const AnchorsNodeName = enum { top, right, bottom, left };
|
||||
pub const MarginsNodeName = enum { top, right, bottom, left };
|
||||
const AnchorsNodeName = enum { top, right, bottom, left };
|
||||
const MarginsNodeName = enum { top, right, bottom, left };
|
||||
|
||||
pub const TagOverlayConfig = struct {
|
||||
border_width: u8 = 2,
|
||||
tag_amount: u8 = 9,
|
||||
tags_per_row: u8 = 32,
|
||||
square_size: u8 = 40,
|
||||
square_inner_padding: u8 = 10,
|
||||
square_padding: u8 = 15,
|
||||
square_border_width: u8 = 1,
|
||||
background_color: pixman.Color = utils.parseRgbaPixmanComptime("0x1e1e2e"),
|
||||
border_color: pixman.Color = utils.parseRgbaPixmanComptime("0x6c7086"),
|
||||
square_active_background_color: pixman.Color = utils.parseRgbaPixmanComptime("0x89b4fa"),
|
||||
square_active_border_color: pixman.Color = utils.parseRgbaPixmanComptime("0x6c7086"),
|
||||
square_active_occupied_color: pixman.Color = utils.parseRgbaPixmanComptime("0xcdd6f4"),
|
||||
square_inactive_background_color: pixman.Color = utils.parseRgbaPixmanComptime("0x585b70"),
|
||||
square_inactive_border_color: pixman.Color = utils.parseRgbaPixmanComptime("0x6c7086"),
|
||||
square_inactive_occupied_color: pixman.Color = utils.parseRgbaPixmanComptime("0xcdd6f4"),
|
||||
timeout: u32 = 500,
|
||||
anchor_top: bool = false,
|
||||
anchor_right: bool = false,
|
||||
anchor_bottom: bool = false,
|
||||
anchor_left: bool = false,
|
||||
margin_top: i32 = 0,
|
||||
margin_right: i32 = 0,
|
||||
margin_bottom: i32 = 0,
|
||||
margin_left: i32 = 0,
|
||||
border_width: u8 = 2,
|
||||
tag_amount: u8 = 9,
|
||||
tags_per_row: u8 = 32,
|
||||
square_size: u8 = 40,
|
||||
square_inner_padding: u8 = 10,
|
||||
square_padding: u8 = 15,
|
||||
square_border_width: u8 = 1,
|
||||
background_color: pixman.Color = utils.parseRgbaPixmanComptime("0x1e1e2e"),
|
||||
border_color: pixman.Color = utils.parseRgbaPixmanComptime("0x6c7086"),
|
||||
square_active_background_color: pixman.Color = utils.parseRgbaPixmanComptime("0x89b4fa"),
|
||||
square_active_border_color: pixman.Color = utils.parseRgbaPixmanComptime("0x6c7086"),
|
||||
square_active_occupied_color: pixman.Color = utils.parseRgbaPixmanComptime("0xcdd6f4"),
|
||||
square_inactive_background_color: pixman.Color = utils.parseRgbaPixmanComptime("0x585b70"),
|
||||
square_inactive_border_color: pixman.Color = utils.parseRgbaPixmanComptime("0x6c7086"),
|
||||
square_inactive_occupied_color: pixman.Color = utils.parseRgbaPixmanComptime("0xcdd6f4"),
|
||||
timeout: u32 = 500,
|
||||
anchor_top: bool = false,
|
||||
anchor_right: bool = false,
|
||||
anchor_bottom: bool = false,
|
||||
anchor_left: bool = false,
|
||||
margin_top: i32 = 0,
|
||||
margin_right: i32 = 0,
|
||||
margin_bottom: i32 = 0,
|
||||
margin_left: i32 = 0,
|
||||
|
||||
pub fn toTagOverlayOptions(config: TagOverlayConfig) TagOverlay.Options {
|
||||
return .{
|
||||
.border_width = config.border_width,
|
||||
.tag_amount = @intCast(std.math.clamp(@as(u32, config.tag_amount), 1, 32)),
|
||||
.tags_per_row = @intCast(std.math.clamp(@as(u32, config.tags_per_row), 1, 32)),
|
||||
.square_size = config.square_size,
|
||||
.square_inner_padding = config.square_inner_padding,
|
||||
.square_padding = config.square_padding,
|
||||
.square_border_width = config.square_border_width,
|
||||
.background_color = config.background_color,
|
||||
.border_color = config.border_color,
|
||||
.square_active_background_color = config.square_active_background_color,
|
||||
.square_active_border_color = config.square_active_border_color,
|
||||
.square_active_occupied_color = config.square_active_occupied_color,
|
||||
.square_inactive_background_color = config.square_inactive_background_color,
|
||||
.square_inactive_border_color = config.square_inactive_border_color,
|
||||
.square_inactive_occupied_color = config.square_inactive_occupied_color,
|
||||
.anchors = .{
|
||||
.top = config.anchor_top,
|
||||
.right = config.anchor_right,
|
||||
.bottom = config.anchor_bottom,
|
||||
.left = config.anchor_left,
|
||||
},
|
||||
.margins = .{
|
||||
.top = config.margin_top,
|
||||
.right = config.margin_right,
|
||||
.bottom = config.margin_bottom,
|
||||
.left = config.margin_left,
|
||||
},
|
||||
.timeout = config.timeout,
|
||||
};
|
||||
}
|
||||
};
|
||||
pub fn toTagOverlayOptions(config: TagOverlayConfig) TagOverlay.Options {
|
||||
return .{
|
||||
.border_width = config.border_width,
|
||||
.tag_amount = @intCast(std.math.clamp(@as(u32, config.tag_amount), 1, 32)),
|
||||
.tags_per_row = @intCast(std.math.clamp(@as(u32, config.tags_per_row), 1, 32)),
|
||||
.square_size = config.square_size,
|
||||
.square_inner_padding = config.square_inner_padding,
|
||||
.square_padding = config.square_padding,
|
||||
.square_border_width = config.square_border_width,
|
||||
.background_color = config.background_color,
|
||||
.border_color = config.border_color,
|
||||
.square_active_background_color = config.square_active_background_color,
|
||||
.square_active_border_color = config.square_active_border_color,
|
||||
.square_active_occupied_color = config.square_active_occupied_color,
|
||||
.square_inactive_background_color = config.square_inactive_background_color,
|
||||
.square_inactive_border_color = config.square_inactive_border_color,
|
||||
.square_inactive_occupied_color = config.square_inactive_occupied_color,
|
||||
.anchors = .{
|
||||
.top = config.anchor_top,
|
||||
.right = config.anchor_right,
|
||||
.bottom = config.anchor_bottom,
|
||||
.left = config.anchor_left,
|
||||
},
|
||||
.margins = .{
|
||||
.top = config.margin_top,
|
||||
.right = config.margin_right,
|
||||
.bottom = config.margin_bottom,
|
||||
.left = config.margin_left,
|
||||
},
|
||||
.timeout = config.timeout,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn load(config: *Config, parser: *kdl.Parser, hostname: ?[]const u8) !void {
|
||||
config.tag_overlay_config = .{}; // Presence of block = enabled; initialize with defaults
|
||||
Loading…
Add table
Add a link
Reference in a new issue