diff options
| author | Isaac Freund <ifreund@ifreund.xyz> | 2020-06-17 22:17:51 +0200 |
|---|---|---|
| committer | Isaac Freund <ifreund@ifreund.xyz> | 2020-06-17 22:17:51 +0200 |
| commit | 582164ce41d3f109d4ae2ef2b945660b352440ef (patch) | |
| tree | 229b7575555755a29f4e49fac1e7c51c62ed8437 | |
| parent | 189d9f2d8b54eefca6d5b4296a5dbe050226e1e3 (diff) | |
| download | river-582164ce41d3f109d4ae2ef2b945660b352440ef.tar.gz river-582164ce41d3f109d4ae2ef2b945660b352440ef.tar.xz | |
code: refactor Server.start()
This was needlessly verbose
| -rw-r--r-- | river/Server.zig | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/river/Server.zig b/river/Server.zig index 3d4307a..5667783 100644 --- a/river/Server.zig +++ b/river/Server.zig @@ -149,27 +149,13 @@ pub fn deinit(self: *Self) void { self.config.deinit(); } -/// Create the socket, set WAYLAND_DISPLAY, and start the backend +/// Create the socket, start the backend, and setup the environment pub fn start(self: Self) !void { - // Add a Unix socket to the Wayland display. - const socket = c.wl_display_add_socket_auto(self.wl_display) orelse - return error.CantAddSocket; - - // Start the backend. This will enumerate outputs and inputs, become the DRM - // master, etc - if (!c.river_wlr_backend_start(self.wlr_backend)) { - return error.CantStartBackend; - } - - // Set the WAYLAND_DISPLAY environment variable to our socket - if (c.setenv("WAYLAND_DISPLAY", socket, 1) == -1) { - return error.CantSetEnv; - } - + const socket = c.wl_display_add_socket_auto(self.wl_display) orelse return error.CantAddSocket; + if (!c.river_wlr_backend_start(self.wlr_backend)) return error.CantStartBackend; + if (c.setenv("WAYLAND_DISPLAY", socket, 1) < 0) return error.CantSetEnv; if (build_options.xwayland) { - if (c.setenv("DISPLAY", &self.wlr_xwayland.display_name, 1) == -1) { - return error.CantSetEnv; - } + if (c.setenv("DISPLAY", &self.wlr_xwayland.display_name, 1) < 0) return error.CantSetEnv; } } |
