mirror of
https://github.com/zoriya/gaze.git
synced 2025-12-06 06:26:13 +00:00
Add exec command and store wlr socket
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,3 +5,4 @@ zig-out/
|
||||
/build/
|
||||
/build-*/
|
||||
/docgen_tmp/
|
||||
vgcore*
|
||||
|
||||
@@ -81,6 +81,8 @@
|
||||
if inShell
|
||||
then [
|
||||
zls-overlay.packages.${system}.default
|
||||
valgrind
|
||||
gdb
|
||||
]
|
||||
else []
|
||||
);
|
||||
|
||||
13
src/commands.zig
Normal file
13
src/commands.zig
Normal file
@@ -0,0 +1,13 @@
|
||||
const std = @import("std");
|
||||
const gpa = std.heap.c_allocator;
|
||||
|
||||
const serv = @import("server.zig");
|
||||
|
||||
pub fn exec(server: *serv.Server, cmd: [:0]const u8) !void {
|
||||
var child = std.ChildProcess.init(&[_][]const u8{ "/bin/sh", "-c", cmd }, gpa);
|
||||
var env_map = try std.process.getEnvMap(gpa);
|
||||
defer env_map.deinit();
|
||||
try env_map.put("WAYLAND_DISPLAY", server.socket);
|
||||
child.env_map = &env_map;
|
||||
try child.spawn();
|
||||
}
|
||||
@@ -20,6 +20,7 @@ pub const Server = struct {
|
||||
cursor: *wlr.Cursor,
|
||||
cursor_mgr: *wlr.XcursorManager,
|
||||
|
||||
socket: [:0]const u8,
|
||||
events: events.Events,
|
||||
|
||||
pub fn init(self: *Server) !void {
|
||||
@@ -29,6 +30,8 @@ pub const Server = struct {
|
||||
const output_layout = try wlr.OutputLayout.create();
|
||||
const scene = try wlr.Scene.create();
|
||||
|
||||
var buf: [11]u8 = undefined;
|
||||
|
||||
self.* = Server{
|
||||
.wl_server = wl_server,
|
||||
.backend = backend,
|
||||
@@ -42,6 +45,7 @@ pub const Server = struct {
|
||||
.cursor = try wlr.Cursor.create(),
|
||||
.cursor_mgr = try wlr.XcursorManager.create(null, 24),
|
||||
.events = undefined,
|
||||
.socket = try wl_server.addSocketAuto(&buf),
|
||||
};
|
||||
errdefer self.destroy();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user