Go back to using std.ChildProcess

The bug with this was fixed by https://github.com/ziglang/zig/pull/4970.
This commit is contained in:
Isaac Freund 2020-04-09 12:54:38 +02:00
parent 6c23f3eefd
commit bf17b54048
No known key found for this signature in database
GPG key ID: 86DED400DDFD7A11
4 changed files with 15 additions and 12 deletions

View file

@ -2,7 +2,6 @@ pub usingnamespace @cImport({
@cDefine("WLR_USE_UNSTABLE", {}); @cDefine("WLR_USE_UNSTABLE", {});
@cInclude("time.h"); @cInclude("time.h");
@cInclude("stdlib.h"); @cInclude("stdlib.h");
@cInclude("unistd.h");
@cInclude("wayland-server-core.h"); @cInclude("wayland-server-core.h");
//@cInclude("wlr/backend.h"); //@cInclude("wlr/backend.h");
//@cInclude("wlr/render/wlr_renderer.h"); //@cInclude("wlr/render/wlr_renderer.h");

View file

@ -9,7 +9,7 @@ pub const Arg = union {
int: i32, int: i32,
uint: u32, uint: u32,
float: f64, float: f64,
cstr: [*:0]const u8, str: []const u8,
none: void, none: void,
}; };
@ -109,13 +109,17 @@ pub fn toggleFocusedViewTags(server: *Server, arg: Arg) void {
/// Spawn a program. /// Spawn a program.
/// TODO: make this take a program as a paramter and spawn that /// TODO: make this take a program as a paramter and spawn that
pub fn spawn(server: *Server, arg: Arg) void { pub fn spawn(server: *Server, arg: Arg) void {
const cmd = arg.cstr; const cmd = arg.str;
if (c.fork() == 0) {
const terminator: ?*u8 = null; const argv = [_][]const u8{ "/bin/sh", "-c", cmd };
if (c.execl("/bin/sh", "/bin/sh", "-c", cmd, terminator) == -1) { const child = std.ChildProcess.init(&argv, std.heap.c_allocator) catch |err| {
Log.Error.log("Failed to execute command {}", .{cmd}); Log.Error.log("Failed to execute {}: {}", .{ cmd, err });
} return;
} };
std.ChildProcess.spawn(child) catch |err| {
Log.Error.log("Failed to execute {}: {}", .{ cmd, err });
return;
};
} }
/// Close the focused view, if any. /// Close the focused view, if any.

View file

@ -54,7 +54,7 @@ pub const Config = struct {
try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_h, .modifiers = mod | c.WLR_MODIFIER_SHIFT, .command = command.modifyMasterCount, .arg = .{ .int = 1 } }); try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_h, .modifiers = mod | c.WLR_MODIFIER_SHIFT, .command = command.modifyMasterCount, .arg = .{ .int = 1 } });
try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_l, .modifiers = mod | c.WLR_MODIFIER_SHIFT, .command = command.modifyMasterCount, .arg = .{ .int = -1 } }); try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_l, .modifiers = mod | c.WLR_MODIFIER_SHIFT, .command = command.modifyMasterCount, .arg = .{ .int = -1 } });
try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_Return, .modifiers = mod | c.WLR_MODIFIER_SHIFT, .command = command.spawn, .arg = .{ .cstr = "alacritty" } }); try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_Return, .modifiers = mod | c.WLR_MODIFIER_SHIFT, .command = command.spawn, .arg = .{ .str = "alacritty" } });
try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_1, .modifiers = mod | c.WLR_MODIFIER_SHIFT, .command = command.setFocusedViewTags, .arg = .{ .uint = 1 << 0 } }); try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_1, .modifiers = mod | c.WLR_MODIFIER_SHIFT, .command = command.setFocusedViewTags, .arg = .{ .uint = 1 << 0 } });
try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_2, .modifiers = mod | c.WLR_MODIFIER_SHIFT, .command = command.setFocusedViewTags, .arg = .{ .uint = 1 << 1 } }); try self.keybinds.append(Keybind{ .keysym = c.XKB_KEY_2, .modifiers = mod | c.WLR_MODIFIER_SHIFT, .command = command.setFocusedViewTags, .arg = .{ .uint = 1 << 1 } });

View file

@ -17,7 +17,7 @@ pub const Keyboard = struct {
pub fn init(self: *Self, seat: *Seat, device: *c.wlr_input_device) !void { pub fn init(self: *Self, seat: *Seat, device: *c.wlr_input_device) !void {
self.seat = seat; self.seat = seat;
self.device = device; self.device = device;
self.wlr_keyboard = device.unnamed_136.keyboard; self.wlr_keyboard = device.unnamed_133.keyboard;
// We need to prepare an XKB keymap and assign it to the keyboard. This // We need to prepare an XKB keymap and assign it to the keyboard. This
// assumes the defaults (e.g. layout = "us"). // assumes the defaults (e.g. layout = "us").
@ -78,7 +78,7 @@ pub const Keyboard = struct {
@alignCast(@alignOf(*c.wlr_event_keyboard_key), data), @alignCast(@alignOf(*c.wlr_event_keyboard_key), data),
); );
const wlr_keyboard: *c.wlr_keyboard = keyboard.device.unnamed_136.keyboard; const wlr_keyboard: *c.wlr_keyboard = keyboard.device.unnamed_133.keyboard;
// Translate libinput keycode -> xkbcommon // Translate libinput keycode -> xkbcommon
const keycode = event.keycode + 8; const keycode = event.keycode + 8;