feat: added ForkOut backend and now forks out to xclip and wl-copy on linux
This commit is contained in:
parent
43c454a08c
commit
c228995f20
4 changed files with 43 additions and 1 deletions
16
src/main.zig
16
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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue