diff options
| author | Grace Yoder <grace_yoder@outlook.com> | 2026-07-03 19:43:26 -0600 |
|---|---|---|
| committer | Grace Yoder <grace_yoder@outlook.com> | 2026-07-03 20:40:06 -0600 |
| commit | c228995f20e16a97ad6baff05a0d46d3fffe3295 (patch) | |
| tree | 005d5c1f517398df287269da59deeb2c35924171 /src/main.zig | |
| parent | 43c454a08c7c169df5c3d3ebcd2abded8bf5fa4b (diff) | |
feat: added ForkOut backend and now forks out to `xclip` and `wl-copy` on linux0.1.1
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig index bb0aa14..60b498d 100644 --- a/src/main.zig +++ b/src/main.zig @@ -42,6 +42,22 @@ pub fn main(init: std.process.Init) !void { return; } + // 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 (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; + } + } + // Fallback Clipboard var clip = try Clip.OSC52.init(alloc, io, size); defer clip.free(); |
