aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/c.zig1
-rw-r--r--src/command.zig20
-rw-r--r--src/config.zig2
-rw-r--r--src/keyboard.zig4
4 files changed, 15 insertions, 12 deletions
diff --git a/src/c.zig b/src/c.zig
index 30a91a6..30d7340 100644
--- a/src/c.zig
+++ b/src/c.zig
@@ -2,7 +2,6 @@ pub usingnamespace @cImport({
@cDefine("WLR_USE_UNSTABLE", {});
@cInclude("time.h");
@cInclude("stdlib.h");
- @cInclude("unistd.h");
@cInclude("wayland-server-core.h");
//@cInclude("wlr/backend.h");
//@cInclude("wlr/render/wlr_renderer.h");
diff --git a/src/command.zig b/src/command.zig
index 6b4ec07..ab290c8 100644
--- a/src/command.zig
+++ b/src/command.zig
@@ -9,7 +9,7 @@ pub const Arg = union {
int: i32,
uint: u32,
float: f64,
- cstr: [*:0]const u8,
+ str: []const u8,
none: void,
};
@@ -109,13 +109,17 @@ pub fn toggleFocusedViewTags(server: *Server, arg: Arg) void {
/// Spawn a program.
/// TODO: make this take a program as a paramter and spawn that
pub fn spawn(server: *Server, arg: Arg) void {
- const cmd = arg.cstr;
- if (c.fork() == 0) {
- const terminator: ?*u8 = null;
- if (c.execl("/bin/sh", "/bin/sh", "-c", cmd, terminator) == -1) {
- Log.Error.log("Failed to execute command {}", .{cmd});
- }
- }
+ const cmd = arg.str;
+
+ const argv = [_][]const u8{ "/bin/sh", "-c", cmd };
+ const child = std.ChildProcess.init(&argv, std.heap.c_allocator) catch |err| {
+ 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.
diff --git a/src/config.zig b/src/config.zig
index c4e7f23..99de35b 100644
--- a/src/config.zig
+++ b/src/config.zig
@@ -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_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_2, .modifiers = mod | c.WLR_MODIFIER_SHIFT, .command = command.setFocusedViewTags, .arg = .{ .uint = 1 << 1 } });
diff --git a/src/keyboard.zig b/src/keyboard.zig
index 83bc745..af2786f 100644
--- a/src/keyboard.zig
+++ b/src/keyboard.zig
@@ -17,7 +17,7 @@ pub const Keyboard = struct {
pub fn init(self: *Self, seat: *Seat, device: *c.wlr_input_device) !void {
self.seat = seat;
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
// assumes the defaults (e.g. layout = "us").
@@ -78,7 +78,7 @@ pub const Keyboard = struct {
@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
const keycode = event.keycode + 8;