port scripts to master zig version

This commit is contained in:
LordMZTE 2022-06-26 18:19:13 +02:00
parent 044a03f9f8
commit aa47de2064
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
4 changed files with 8 additions and 11 deletions

View file

@ -7,6 +7,7 @@ shfmt
taplo-cli
vscode-langservers-extracted
yaml-language-server
zls-bin
"
install-scripts target=(`echo $HOME` + "/.local/bin"): build-scripts

View file

@ -7,8 +7,8 @@ pub const GuiState = struct {
/// An arena allocator used to store userdata for widgets of the UI
udata_arena: std.mem.Allocator,
streamlink_child: ?*std.ChildProcess = null,
chatty_child: ?*std.ChildProcess = null,
streamlink_child: ?std.ChildProcess = null,
chatty_child: ?std.ChildProcess = null,
};
pub fn activate(app: *c.GtkApplication, state: *GuiState) void {
@ -166,13 +166,13 @@ fn start(state: *GuiState, chatty: bool, channel: []const u8) !void {
const url = try std.fmt.allocPrint(state.alloc, "https://twitch.tv/{s}", .{channel});
const streamlink_argv = [_][]const u8{ "streamlink", url };
const streamlink_child = try std.ChildProcess.init(&streamlink_argv, state.alloc);
var streamlink_child = std.ChildProcess.init(&streamlink_argv, state.alloc);
try streamlink_child.spawn();
state.streamlink_child = streamlink_child;
if (chatty) {
const chatty_argv = [_][]const u8{ "chatty", "-connect", "-channel", channel };
const chatty_child = try std.ChildProcess.init(&chatty_argv, state.alloc);
var chatty_child = std.ChildProcess.init(&chatty_argv, state.alloc);
try chatty_child.spawn();
state.chatty_child = chatty_child;
}

View file

@ -63,13 +63,11 @@ pub fn main() !u8 {
@ptrCast([*c][*c]u8, std.os.argv.ptr),
);
if (state.streamlink_child) |ch| {
defer ch.deinit();
if (state.streamlink_child) |*ch| {
_ = try ch.wait();
}
if (state.chatty_child) |ch| {
defer ch.deinit();
if (state.chatty_child) |*ch| {
_ = try ch.wait();
}

View file

@ -34,9 +34,7 @@ pub fn main() !u8 {
feh_argv[2 + i] = walker.files.items[idx];
}
var child = try std.ChildProcess.init(feh_argv, alloc);
defer child.deinit();
const term = try child.spawnAndWait();
const term = try std.ChildProcess.init(feh_argv, alloc).spawnAndWait();
const exit = switch (term) {
.Exited => |n| n,