summaryrefslogtreecommitdiff
path: root/src/host/Host.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/host/Host.zig')
-rw-r--r--src/host/Host.zig12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/host/Host.zig b/src/host/Host.zig
index 93c47c1..135f5c4 100644
--- a/src/host/Host.zig
+++ b/src/host/Host.zig
@@ -284,7 +284,15 @@ pub fn deinit(self: *Host) void {
/// The interactive loop. An export runs it on a clock of its own, frame k
/// at k/fps seconds (from 1 s, as scripts do), whatever the wall clock says.
pub fn run(self: *Host) !void {
- if (self.options.ninep) |path| self.control = try Control.init(self.gpa, path);
+ // A run a person watches posts its tree as sketchbook/<name>; --9p
+ // names another, or a socket path.
+ const o = self.options;
+ const ninep = o.ninep orelse if (o.headless or o.script or o.export_to != null) null else self.name;
+ if (ninep) |where| self.control = Control.open(self.gpa, self.environ, where) catch |err| blk: {
+ if (o.ninep != null) return err;
+ self.print("not posted as sketchbook/{s}: {t}", .{ where, err });
+ break :blk null;
+ };
while (!self.quit) {
if (self.control) |control| control.poll(self);
try self.poll();
@@ -1036,7 +1044,7 @@ fn fileId(io: std.Io, path: []const u8) u64 {
return std.hash.Wyhash.hash(0, std.mem.asBytes(&id)) | 1;
}
-fn scratchDir(environ: *const std.process.Environ.Map) []const u8 {
+pub fn scratchDir(environ: *const std.process.Environ.Map) []const u8 {
return environ.get("XDG_RUNTIME_DIR") orelse "/tmp";
}