From ec524f039c7af886a26bb401ba88eae4a5d31285 Mon Sep 17 00:00:00 2001 From: Grace Yoder Date: Mon, 6 Jul 2026 09:49:35 -0600 Subject: [PATCH] fix: added os comptime check for running ForkOut --- src/main.zig | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main.zig b/src/main.zig index 60b498d..36c5bde 100644 --- a/src/main.zig +++ b/src/main.zig @@ -45,16 +45,18 @@ pub fn main(init: std.process.Init) !void { // I don't like this but it will stay until I review how dispatch works // with zig since I will probably be refactoring there linux: { - const xdg_type = init.environ_map.get("XDG_SESSION_TYPE") orelse ""; + if (comptime os == .linux) { + const xdg_type = init.environ_map.get("XDG_SESSION_TYPE") orelse ""; - if (std.mem.eql(u8, xdg_type, "wayland")) { - var clip = Clip.ForkOut.init(io, &[_][]const u8{"wl-copy"}) catch break :linux; - try run(io, &clip); - return; - } else if (std.mem.eql(u8, xdg_type, "x11")) { - var clip = Clip.ForkOut.init(io, &[_][]const u8{ "xclip", "-selection", "clipboard" }) catch break :linux; - try run(io, &clip); - return; + if (std.mem.eql(u8, xdg_type, "wayland")) { + var clip = Clip.ForkOut.init(io, &[_][]const u8{"wl-copy"}) catch break :linux; + try run(io, &clip); + return; + } else if (std.mem.eql(u8, xdg_type, "x11")) { + var clip = Clip.ForkOut.init(io, &[_][]const u8{ "xclip", "-selection", "clipboard" }) catch break :linux; + try run(io, &clip); + return; + } } }