fix: added os comptime check for running ForkOut
This commit is contained in:
parent
c228995f20
commit
ec524f039c
1 changed files with 11 additions and 9 deletions
20
src/main.zig
20
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue