From b35962606dc1f67a9037b96d366325df7e285d75 Mon Sep 17 00:00:00 2001 From: Zhongheng Liu Date: Tue, 28 Apr 2026 20:40:12 +0200 Subject: [PATCH] impl autoexec support for a single script file --- src/Config.zig | 11 +++++++++++ src/main.zig | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Config.zig b/src/Config.zig index b89bfe3..2a3c023 100644 --- a/src/Config.zig +++ b/src/Config.zig @@ -16,6 +16,9 @@ border_color_focused: RiverColor = utils.parseRgbaComptime("0x89b4fa"), /// Color of unfocused windows' borders in 0xRRGGBBAA or 0xRRGGBB form border_color_unfocused: RiverColor = utils.parseRgbaComptime("0x1e1e2e"), +/// Autoexec script path +autoexec_path: ?[]const u8 = null, + /// Number of windows in the primary stack /// This is a global default, but each tagmask can have its own value primary_count: u8 = 1, @@ -70,6 +73,7 @@ pub const PrimarySide = enum { left, right }; pub const AttachMode = enum { top, bottom }; const NodeName = enum { + autoexec, attach_mode, primary_count, primary_ratio, @@ -225,6 +229,13 @@ fn load(config: *Config, reader: *Io.Reader) !void { } // Next, we have to check the specifics for the NodeName switch (name) { + .autoexec => { + const autoexec_path = node.arg(&parser, 0); + if (autoexec_path) |path| { + config.autoexec_path = utils.gpa.dupe(u8, path) catch @panic("Out of memory"); + } + logDebugSettingNode(name, autoexec_path.?); + }, .primary_count => { const count_str = utils.stripQuotes(node.arg(&parser, 0) orelse ""); // Use @max to ensure a minimum of 1 diff --git a/src/main.zig b/src/main.zig index 6da367a..db012ab 100644 --- a/src/main.zig +++ b/src/main.zig @@ -84,7 +84,12 @@ pub fn main() !void { .config = config, }); defer context.destroy(); - + if (context.config.autoexec_path) |path| { + std.log.debug("Path: {s}", .{path}); + const argv = [_][]const u8{"/bin/sh", "-c", path }; + var child = std.process.Child.init(&argv, utils.gpa); + try child.spawn(); + } try run(wl_display, context); }