From c228995f20e16a97ad6baff05a0d46d3fffe3295 Mon Sep 17 00:00:00 2001 From: Grace Yoder Date: Fri, 3 Jul 2026 19:43:26 -0600 Subject: feat: added ForkOut backend and now forks out to `xclip` and `wl-copy` on linux --- src/Clip/ForkOut.zig | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/Clip/ForkOut.zig (limited to 'src/Clip') diff --git a/src/Clip/ForkOut.zig b/src/Clip/ForkOut.zig new file mode 100644 index 0000000..97c5377 --- /dev/null +++ b/src/Clip/ForkOut.zig @@ -0,0 +1,24 @@ +/// ForkOut Clipboard backend +/// Fulfills `Clip` interface +pub const ForkOut = @This(); + +const std = @import("std"); + +extern fn sendPB(text: [*:0]const u8) void; +extern fn initPB() void; + +io: std.Io, + +child: std.process.Child, + +pub fn init(io: std.Io, argv: []const []const u8) !ForkOut { + return .{ .child = try std.process.spawn(io, .{ .argv = argv, .stdin = .pipe }), .io = io }; +} + +pub fn writeCopyBuffer(self: *ForkOut, buf: []const u8) anyerror!void { + try self.child.stdin.?.writeStreamingAll(self.io, buf); +} + +pub fn writePasteboard(self: *ForkOut) anyerror!void { + self.child.stdin.?.close(self.io); +} -- cgit v1.3.1