diff --git a/plugins/mzte-mpv/src/modules/LiveChat.zig b/plugins/mzte-mpv/src/modules/LiveChat.zig index 0d04b92..056c385 100644 --- a/plugins/mzte-mpv/src/modules/LiveChat.zig +++ b/plugins/mzte-mpv/src/modules/LiveChat.zig @@ -7,6 +7,8 @@ const c = ffi.c; const ffi = @import("../ffi.zig"); const util = @import("../util.zig"); +const log = std.log.scoped(.@"live-chat"); + // Zig segfaults when this is a ZST padding: u1 = 0, @@ -33,9 +35,9 @@ pub fn onEvent(self: *LiveChat, mpv: *c.mpv_handle, ev: *c.mpv_event) !void { else => return e, }; errdefer file.close(); - std.log.info("initializing subtitle transcoder: {s}", .{fname}); + log.info("initializing subtitle transcoder: {s}", .{fname}); - const pipe = try std.os.pipe2(.{}); + const pipe = try std.posix.pipe2(.{}); // This needs to be done here instead of the separate thread. MPV will instantly // give up if there's nothing to be read from the pipe when the command is called. @@ -85,7 +87,7 @@ fn transcoderThread(jsonf: std.fs.File, pipefd: std.c.fd_t) !void { else => return e, }; processLine(line_buf.items, pipe.writer()) catch |e| { - std.log.warn("failed to parse chat entry: {}", .{e}); + log.warn("failed to parse chat entry: {}", .{e}); }; } diff --git a/plugins/mzte-mpv/src/modules/SBSkip.zig b/plugins/mzte-mpv/src/modules/SBSkip.zig index f06a477..cea5664 100644 --- a/plugins/mzte-mpv/src/modules/SBSkip.zig +++ b/plugins/mzte-mpv/src/modules/SBSkip.zig @@ -4,6 +4,8 @@ const c = ffi.c; const ffi = @import("../ffi.zig"); const util = @import("../util.zig"); +const log = std.log.scoped(.@"sb-skip"); + const ChapterSet = std.AutoHashMap(isize, void); skipped_chapters: ChapterSet, @@ -84,7 +86,7 @@ fn onChapterChange( @constCast(&end_time), )); try self.skipped_chapters.put(chapter_id, {}); - try util.msg(mpv, "skipped: {s}", .{reason}); + try util.msg(mpv, .@"sb-skip", "skipped: {s}", .{reason}); } } diff --git a/plugins/mzte-mpv/src/util.zig b/plugins/mzte-mpv/src/util.zig index 066ce63..40090ac 100644 --- a/plugins/mzte-mpv/src/util.zig +++ b/plugins/mzte-mpv/src/util.zig @@ -3,11 +3,16 @@ const c = ffi.c; const ffi = @import("ffi.zig"); -pub fn msg(mpv: *c.mpv_handle, comptime fmt: []const u8, args: anytype) !void { - std.log.info(fmt, args); +pub fn msg( + mpv: *c.mpv_handle, + scope: @TypeOf(.enum_tag), + comptime fmt: []const u8, + args: anytype, +) !void { + std.log.scoped(scope).info(fmt, args); var buf: [1024 * 4]u8 = undefined; - const osd_msg = try std.fmt.bufPrintZ(&buf, "[sbskip] " ++ fmt, args); + const osd_msg = try std.fmt.bufPrintZ(&buf, "[mzte-mpv " ++ @tagName(scope) ++ "] " ++ fmt, args); try ffi.checkMpvError(c.mpv_command( mpv, @constCast(&[_:null]?[*:0]const u8{ "show-text", osd_msg, "4000" }), diff --git a/scripts/alecor/src/cache.zig b/scripts/alecor/src/cache.zig index 5aeeec7..97d1865 100644 --- a/scripts/alecor/src/cache.zig +++ b/scripts/alecor/src/cache.zig @@ -2,7 +2,7 @@ const std = @import("std"); pub fn commandsCachePath(alloc: std.mem.Allocator) ![]const u8 { return try std.fs.path.join(alloc, &.{ - std.os.getenv("HOME") orelse return error.HomeNotSet, + std.posix.getenv("HOME") orelse return error.HomeNotSet, ".cache", "alecor", "commands", @@ -20,26 +20,26 @@ pub fn generate(alloc: std.mem.Allocator) !void { var cache_file = try std.fs.cwd().createFile(cache_path, .{}); defer cache_file.close(); - const pipefds = try std.os.pipe(); - defer std.os.close(pipefds[0]); + const pipefds = try std.posix.pipe(); + defer std.posix.close(pipefds[0]); var stdout_buf_reader = std.io.bufferedReader((std.fs.File{ .handle = pipefds[0] }).reader()); // ChildProcess being useless again... - const pid = try std.os.fork(); + const pid = try std.posix.fork(); if (pid == 0) { - errdefer std.os.exit(1); - try std.os.dup2(pipefds[1], 1); - std.os.close(pipefds[0]); - std.os.close(pipefds[1]); - return std.os.execvpeZ( + errdefer std.posix.exit(1); + try std.posix.dup2(pipefds[1], 1); + std.posix.close(pipefds[0]); + std.posix.close(pipefds[1]); + return std.posix.execvpeZ( "fish", &[_:null]?[*:0]const u8{ "fish", "-c", "complete -C ''" }, @ptrCast(std.os.environ.ptr), ); } - std.os.close(pipefds[1]); + std.posix.close(pipefds[1]); var cmd_buf: [1024]u8 = undefined; var fbs = std.io.fixedBufferStream(&cmd_buf); @@ -56,5 +56,5 @@ pub fn generate(alloc: std.mem.Allocator) !void { try cache_file.writer().writeByte('\n'); } - _ = std.os.waitpid(pid, 0); + _ = std.posix.waitpid(pid, 0); } diff --git a/scripts/alecor/src/correct.zig b/scripts/alecor/src/correct.zig index 7c1037e..a607bc8 100644 --- a/scripts/alecor/src/correct.zig +++ b/scripts/alecor/src/correct.zig @@ -170,7 +170,7 @@ fn correctArgForReq(arena: *std.heap.ArenaAllocator, req: ArgRequirement, arg: * while (path_spliter.next()) |split| { if (std.mem.eql(u8, split, "~")) { - try path_splits.append(std.os.getenv("HOME") orelse return error.HomeNotSet); + try path_splits.append(std.posix.getenv("HOME") orelse return error.HomeNotSet); } else { try path_splits.append(split); } diff --git a/scripts/alecor/src/main.zig b/scripts/alecor/src/main.zig index aa0c59a..cd614d1 100644 --- a/scripts/alecor/src/main.zig +++ b/scripts/alecor/src/main.zig @@ -36,15 +36,15 @@ pub fn main() !void { var cache_file = try std.fs.cwd().openFile(cache_path, .{}); defer cache_file.close(); - const cache_content = try std.os.mmap( + const cache_content = try std.posix.mmap( null, (try cache_file.stat()).size, - std.os.PROT.READ, + std.posix.PROT.READ, .{ .TYPE = .PRIVATE }, cache_file.handle, 0, ); - defer std.os.munmap(cache_content); + defer std.posix.munmap(cache_content); var command_set = std.StringHashMap(void).init(alloc); defer command_set.deinit(); diff --git a/scripts/hyprtool/src/main.zig b/scripts/hyprtool/src/main.zig index c455dd5..b78109e 100644 --- a/scripts/hyprtool/src/main.zig +++ b/scripts/hyprtool/src/main.zig @@ -9,7 +9,7 @@ pub fn main() !void { if (std.os.argv.len != 2 or !std.mem.eql(u8, std.mem.span(std.os.argv[1]), "fullerscreen")) return error.InvalidArgs; - const inst_sig = std.os.getenv("HYPRLAND_INSTANCE_SIGNATURE") orelse + const inst_sig = std.posix.getenv("HYPRLAND_INSTANCE_SIGNATURE") orelse return error.MissingInstanceSignature; var gpa = std.heap.GeneralPurposeAllocator(.{}){}; diff --git a/scripts/mzteinit/src/main.zig b/scripts/mzteinit/src/main.zig index cf720e2..6c5f1d5 100644 --- a/scripts/mzteinit/src/main.zig +++ b/scripts/mzteinit/src/main.zig @@ -44,7 +44,7 @@ pub fn main() void { } std.debug.print("Encountered fatal error (check log), starting emergency shell!\n", .{}); - @panic(@errorName(std.os.execveZ( + @panic(@errorName(std.posix.execveZ( "/bin/sh", &[_:null]?[*:0]const u8{"/bin/sh"}, &[_:null]?[*:0]const u8{}, @@ -187,7 +187,7 @@ fn ui(buf_writer: anytype, entries: []command.Command) !command.Command { var style: ?at.style.Style = null; try @import("figlet.zig").writeFiglet(w); - const uname = std.os.uname(); + const uname = std.posix.uname(); try updateStyle(w, .{ .foreground = .Yellow }, &style); try w.print( "\n {s} {s} {s}\n\n", @@ -212,11 +212,11 @@ fn ui(buf_writer: anytype, entries: []command.Command) !command.Command { try buf_writer.flush(); - const old_termios = try std.os.tcgetattr(std.os.STDIN_FILENO); + const old_termios = try std.posix.tcgetattr(std.posix.STDIN_FILENO); var new_termios = old_termios; new_termios.lflag.ICANON = false; // No line buffering new_termios.lflag.ECHO = false; // No echoing stuff - try std.os.tcsetattr(std.os.STDIN_FILENO, .NOW, new_termios); + try std.posix.tcsetattr(std.posix.STDIN_FILENO, .NOW, new_termios); var cmd: ?command.Command = null; var c: [1]u8 = undefined; @@ -233,7 +233,7 @@ fn ui(buf_writer: anytype, entries: []command.Command) !command.Command { try buf_writer.flush(); } } - try std.os.tcsetattr(std.os.STDIN_FILENO, .NOW, old_termios); + try std.posix.tcsetattr(std.posix.STDIN_FILENO, .NOW, old_termios); return cmd.?; } diff --git a/scripts/mzteinit/src/mzteinitctl.zig b/scripts/mzteinit/src/mzteinitctl.zig index 5956ac4..4ff3131 100644 --- a/scripts/mzteinit/src/mzteinitctl.zig +++ b/scripts/mzteinit/src/mzteinitctl.zig @@ -19,7 +19,7 @@ pub fn main() !void { if (std.mem.eql(u8, verb, "ping")) { const client = try Client.connect( - std.os.getenv("MZTEINIT_SOCKET") orelse return error.SocketPathUnknown, + std.posix.getenv("MZTEINIT_SOCKET") orelse return error.SocketPathUnknown, ); defer client.deinit(); @@ -28,7 +28,7 @@ pub fn main() !void { if (std.os.argv.len < 3) return error.InvalidArgs; - const client = if (std.os.getenv("MZTEINIT_SOCKET")) |sockpath| + const client = if (std.posix.getenv("MZTEINIT_SOCKET")) |sockpath| try Client.connect(sockpath) else nosock: { std.log.warn("MZTEINIT_SOCKET not set", .{}); @@ -44,7 +44,7 @@ pub fn main() !void { const val = mzteinit_val orelse getenv: { std.log.warn("Variable not known to MZTEINIT, falling back to current environment.", .{}); - break :getenv std.os.getenv(std.mem.span(std.os.argv[2])); + break :getenv std.posix.getenv(std.mem.span(std.os.argv[2])); }; if (val) |v| { diff --git a/scripts/mzteinit/src/util.zig b/scripts/mzteinit/src/util.zig index 5193b90..22f4efb 100644 --- a/scripts/mzteinit/src/util.zig +++ b/scripts/mzteinit/src/util.zig @@ -48,7 +48,7 @@ pub fn fmtCommand(cmd: []const []const u8) std.fmt.Formatter(formatCommand) { } pub fn findInPath(alloc: std.mem.Allocator, bin: []const u8) !?[]const u8 { - const path = std.os.getenv("PATH") orelse return null; + const path = std.posix.getenv("PATH") orelse return null; var splits = std.mem.split(u8, path, ":"); while (splits.next()) |p| { diff --git a/scripts/mzteriver/build.zig.zon b/scripts/mzteriver/build.zig.zon index 83994cf..7b7480d 100644 --- a/scripts/mzteriver/build.zig.zon +++ b/scripts/mzteriver/build.zig.zon @@ -5,8 +5,8 @@ .dependencies = .{ .common = .{ .path = "../../lib/common-zig" }, .wayland = .{ - .url = "git+https://git.mzte.de/LordMZTE/zig-wayland#4de9f2d6d5fddae1fbb29e21fd1dae69e646ab7d", - .hash = "1220d6448c277e5c41348aa95ce2ba2fc92a92cb7a9e9783edf0f816cd0260122d31", + .url = "git+https://git.mzte.de/LordMZTE/zig-wayland#4f4ade382d582845b092de450527e3e7e0133f07", + .hash = "122087ee3bdff43049bf1d58513622c5f3c1430308665af0ee8961a22b60c4c10c1a", }, }, diff --git a/scripts/mzteriver/src/init.zig b/scripts/mzteriver/src/init.zig index 1e9436c..c9d2889 100644 --- a/scripts/mzteriver/src/init.zig +++ b/scripts/mzteriver/src/init.zig @@ -163,7 +163,7 @@ pub fn init(alloc: std.mem.Allocator, initial: bool) !void { try con.runCommand(&.{ "default-layout", "rivertile" }); - const home = std.os.getenv("HOME") orelse return error.HomeNotSet; + const home = std.posix.getenv("HOME") orelse return error.HomeNotSet; const init_path = try std.fs.path.join( alloc, &.{ home, ".config", "mzte_localconf", "river_init" }, diff --git a/scripts/mzteriver/src/main.zig b/scripts/mzteriver/src/main.zig index 46b378e..60a2543 100644 --- a/scripts/mzteriver/src/main.zig +++ b/scripts/mzteriver/src/main.zig @@ -43,8 +43,8 @@ pub fn main() !void { std.log.info("river log file: {s}", .{logf_path}); - break :logf try std.os.openatZ( - std.os.AT.FDCWD, + break :logf try std.posix.openatZ( + std.posix.AT.FDCWD, logf_path.ptr, // no CLOEXEC .{ @@ -56,13 +56,13 @@ pub fn main() !void { ); }; { - errdefer std.os.close(logfd); + errdefer std.posix.close(logfd); // redirect river's STDERR and STDOUT to log file - try std.os.dup2(logfd, std.os.STDOUT_FILENO); - try std.os.dup2(logfd, std.os.STDERR_FILENO); + try std.posix.dup2(logfd, std.posix.STDOUT_FILENO); + try std.posix.dup2(logfd, std.posix.STDERR_FILENO); } - std.os.close(logfd); + std.posix.close(logfd); var env = std.BoundedArray(?[*:0]const u8, 0xff).init(0) catch unreachable; const envp: [*:null]?[*:0]const u8 = env: { @@ -81,6 +81,6 @@ pub fn main() !void { break :env @ptrCast(env.slice().ptr); }; - return std.os.execvpeZ("river", &[_:null]?[*:0]const u8{"river"}, envp); + return std.posix.execvpeZ("river", &[_:null]?[*:0]const u8{"river"}, envp); } } diff --git a/scripts/playvid/src/main.zig b/scripts/playvid/src/main.zig index 4f0a0f1..5e334e4 100644 --- a/scripts/playvid/src/main.zig +++ b/scripts/playvid/src/main.zig @@ -10,7 +10,7 @@ pub fn main() !u8 { defer _ = gpa.deinit(); const alloc = gpa.allocator(); - var file_buf: [std.os.PATH_MAX]u8 = undefined; + var file_buf: [std.posix.PATH_MAX]u8 = undefined; const file = try findVideoFile(alloc, &file_buf); try std.io.getStdOut().writer().print("playing: `{s}`\n", .{file}); @@ -68,11 +68,11 @@ fn findVideoFile(alloc: std.mem.Allocator, out_buf: []u8) ![]const u8 { fn promtForDeletion(file: []const u8) !bool { try std.io.getStdOut().writer().print("delete file `{s}`? [Y/N] ", .{file}); - const old_termios = try std.os.tcgetattr(std.os.STDIN_FILENO); + const old_termios = try std.posix.tcgetattr(std.posix.STDIN_FILENO); var new_termios = old_termios; new_termios.lflag.ICANON = false; // No line buffering - try std.os.tcsetattr(std.os.STDIN_FILENO, .NOW, new_termios); - defer std.os.tcsetattr(std.os.STDIN_FILENO, .NOW, old_termios) catch {}; + try std.posix.tcsetattr(std.posix.STDIN_FILENO, .NOW, new_termios); + defer std.posix.tcsetattr(std.posix.STDIN_FILENO, .NOW, old_termios) catch {}; const answer = try std.io.getStdIn().reader().readByte(); const ret = switch (answer) { diff --git a/scripts/prompt/src/main.zig b/scripts/prompt/src/main.zig index d25d154..d379a49 100644 --- a/scripts/prompt/src/main.zig +++ b/scripts/prompt/src/main.zig @@ -31,23 +31,23 @@ pub fn main() !void { const options = prompt.Options{ .status = try std.fmt.parseInt( i16, - std.os.getenv("MZPROMPT_STATUS") orelse + std.posix.getenv("MZPROMPT_STATUS") orelse return error.MissingEnv, 10, ), .mode = FishMode.parse( - std.os.getenv("MZPROMPT_FISH_MODE") orelse + std.posix.getenv("MZPROMPT_FISH_MODE") orelse return error.MissingEnv, ), .duration = try std.fmt.parseInt( u32, - std.os.getenv("MZPROMPT_DURATION") orelse + std.posix.getenv("MZPROMPT_DURATION") orelse return error.MissingEnv, 10, ), .jobs = try std.fmt.parseInt( u32, - std.os.getenv("MZPROMPT_JOBS") orelse + std.posix.getenv("MZPROMPT_JOBS") orelse return error.MissingEnv, 10, ), diff --git a/scripts/prompt/src/prompt.zig b/scripts/prompt/src/prompt.zig index 51b1ce8..cd5deac 100644 --- a/scripts/prompt/src/prompt.zig +++ b/scripts/prompt/src/prompt.zig @@ -149,7 +149,7 @@ fn Renderer(comptime Writer: type) type { fn renderCwd(self: *Self) !void { var cwd_buf: [512]u8 = undefined; - const cwd = try std.os.getcwd(&cwd_buf); + const cwd = try std.posix.getcwd(&cwd_buf); const home_path = (try known_folders.getPath(std.heap.c_allocator, .home)); diff --git a/scripts/randomwallpaper/src/main.zig b/scripts/randomwallpaper/src/main.zig index f607c8f..d5576ae 100644 --- a/scripts/randomwallpaper/src/main.zig +++ b/scripts/randomwallpaper/src/main.zig @@ -9,8 +9,8 @@ pub const std_options = std.Options{ pub fn main() !u8 { const alloc = std.heap.c_allocator; - const home_s = std.os.getenv("HOME") orelse return error.HomeNotSet; - const runtime_dir = std.os.getenv("XDG_RUNTIME_DIR") orelse return error.MissingRuntimeDir; + const home_s = std.posix.getenv("HOME") orelse return error.HomeNotSet; + const runtime_dir = std.posix.getenv("XDG_RUNTIME_DIR") orelse return error.MissingRuntimeDir; var walker = Walker.init(alloc); defer walker.deinit(); diff --git a/scripts/vinput/build.zig.zon b/scripts/vinput/build.zig.zon index 211b5e9..06dbd37 100644 --- a/scripts/vinput/build.zig.zon +++ b/scripts/vinput/build.zig.zon @@ -5,8 +5,8 @@ .dependencies = .{ .common = .{ .path = "../../lib/common-zig" }, .wayland = .{ - .url = "git+https://git.mzte.de/LordMZTE/zig-wayland#4de9f2d6d5fddae1fbb29e21fd1dae69e646ab7d", - .hash = "1220d6448c277e5c41348aa95ce2ba2fc92a92cb7a9e9783edf0f816cd0260122d31", + .url = "git+https://git.mzte.de/LordMZTE/zig-wayland#4f4ade382d582845b092de450527e3e7e0133f07", + .hash = "122087ee3bdff43049bf1d58513622c5f3c1430308665af0ee8961a22b60c4c10c1a", }, }, } diff --git a/scripts/vinput/src/ClipboardConnection.zig b/scripts/vinput/src/ClipboardConnection.zig index 725d951..e91737d 100644 --- a/scripts/vinput/src/ClipboardConnection.zig +++ b/scripts/vinput/src/ClipboardConnection.zig @@ -50,9 +50,9 @@ const PopupWindow = struct { const stride = width * 4; const size = stride * height; // 1x1x4 bytes - const memfd = try std.os.memfd_create("surface_shm", 0); - defer std.os.close(memfd); - try std.os.ftruncate(memfd, size); + const memfd = try std.posix.memfd_create("surface_shm", 0); + defer std.posix.close(memfd); + try std.posix.ftruncate(memfd, size); const shm_pool = try cc.shm.createPool(memfd, size); errdefer shm_pool.destroy(); @@ -123,9 +123,9 @@ pub fn deinit(self: *ClipboardConnection) void { self.* = undefined; } -pub fn getContent(self: *ClipboardConnection, out_fd: std.os.fd_t) !void { +pub fn getContent(self: *ClipboardConnection, out_fd: std.posix.fd_t) !void { const DataDeviceListener = struct { - out_fd: std.os.fd_t, + out_fd: std.posix.fd_t, display: *wl.Display, fn onEvent(_: *wl.DataDevice, ev: wl.DataDevice.Event, ddl: *@This()) void { diff --git a/scripts/vinput/src/main.zig b/scripts/vinput/src/main.zig index b92ad83..cb909ec 100644 --- a/scripts/vinput/src/main.zig +++ b/scripts/vinput/src/main.zig @@ -83,15 +83,15 @@ pub fn main() !void { std.log.info("mmapping tempfile", .{}); - const fcontent = try std.os.mmap( + const fcontent = try std.posix.mmap( null, stat.size, - std.os.PROT.READ, + std.posix.PROT.READ, .{ .TYPE = .PRIVATE }, tempfile.handle, 0, ); - defer std.os.munmap(fcontent); + defer std.posix.munmap(fcontent); try cp.serveContent(std.mem.trim(u8, fcontent, " \n\r")); } diff --git a/scripts/wlbg/build.zig.zon b/scripts/wlbg/build.zig.zon index de87aa7..c3b295e 100644 --- a/scripts/wlbg/build.zig.zon +++ b/scripts/wlbg/build.zig.zon @@ -5,12 +5,12 @@ .dependencies = .{ .common = .{ .path = "../../lib/common-zig" }, .wayland = .{ - .url = "git+https://git.mzte.de/LordMZTE/zig-wayland#4de9f2d6d5fddae1fbb29e21fd1dae69e646ab7d", - .hash = "1220d6448c277e5c41348aa95ce2ba2fc92a92cb7a9e9783edf0f816cd0260122d31", + .url = "git+https://git.mzte.de/LordMZTE/zig-wayland#4f4ade382d582845b092de450527e3e7e0133f07", + .hash = "122087ee3bdff43049bf1d58513622c5f3c1430308665af0ee8961a22b60c4c10c1a", }, .xev = .{ - .url = "git+https://github.com/mitchellh/libxev#418cac65473668b02cc5a85194042bdaf04acd00", - .hash = "12203116ff408eb48f81c947dfeb06f7feebf6a9efa962a560ac69463098b2c04a96", + .url = "git+https://github.com/mitchellh/libxev#0f73adfda1cff9c740160717b5431ebada6b8755", + .hash = "12203dcbe098ee49ea242432cd198b1ca557626988f056bea86630dcfe8660244407", }, }, }