From b8e08d056c4db700de50115a5c5d5ccda3e13e50 Mon Sep 17 00:00:00 2001 From: pop-ecx Date: Tue, 13 Jan 2026 09:04:51 +0300 Subject: [PATCH 1/2] fmt: after zig fmt --- src/ascii_art.zig | 3 +-- src/hardware.zig | 24 ++++-------------------- src/main.zig | 2 +- src/system.zig | 3 +-- 4 files changed, 7 insertions(+), 25 deletions(-) diff --git a/src/ascii_art.zig b/src/ascii_art.zig index 1f9d218..e76da70 100644 --- a/src/ascii_art.zig +++ b/src/ascii_art.zig @@ -1,6 +1,5 @@ const std = @import("std"); - // We stop assuming logo lines is of the same length as the info block fn safeNextLine(iter: *std.mem.SplitIterator(u8, .sequence)) []const u8 { return iter.next() orelse ""; @@ -42,7 +41,7 @@ pub fn printNeofetchStyle( std.debug.print("{s}{s:<60}{s} {s}{s}Packages:{s} {}\n", .{ color, safeNextLine(&logo_lines), reset, key_color, bold, reset, package_count }); std.debug.print("{s}{s:<60}{s} {s}{s}Hardware Model:{s} {s}\n", .{ color, safeNextLine(&logo_lines), reset, key_color, bold, reset, hardware_model }); std.debug.print("{s}{s:<60}{s} {s}{s}CPU:{s} {s}\n", .{ color, safeNextLine(&logo_lines), reset, key_color, bold, reset, cpu }); - std.debug.print("{s}{s:<60}{s} {s}{s}GPU:{s} {s}\n", .{ color, safeNextLine(&logo_lines), reset,key_color, bold, reset, gpu }); + std.debug.print("{s}{s:<60}{s} {s}{s}GPU:{s} {s}\n", .{ color, safeNextLine(&logo_lines), reset, key_color, bold, reset, gpu }); std.debug.print("{s}{s:<60}{s} {s}{s}Terminal:{s} {s}\n", .{ color, safeNextLine(&logo_lines), reset, key_color, bold, reset, terminal_name }); std.debug.print("{s}{s:<60}{s} {s}{s}Theme:{s} {s}\n", .{ color, safeNextLine(&logo_lines), reset, key_color, bold, reset, theme }); std.debug.print("{s}{s:<60}{s} {s}{s}Icons:{s} {s}\n", .{ color, safeNextLine(&logo_lines), reset, key_color, bold, reset, icons }); diff --git a/src/hardware.zig b/src/hardware.zig index ac40689..306b5b6 100644 --- a/src/hardware.zig +++ b/src/hardware.zig @@ -52,11 +52,7 @@ pub fn getGPUInfo(allocator: std.mem.Allocator) ![]u8 { var lines = std.mem.splitSequence(u8, lspci_output, "\n"); while (lines.next()) |line| { if (std.mem.indexOf(u8, line, "VGA compatible controller:")) |vga_index| { - const gpu_info = std.mem.trim( - u8, - line[vga_index + "VGA compatible controller:".len ..], - " " - ); + const gpu_info = std.mem.trim(u8, line[vga_index + "VGA compatible controller:".len ..], " "); return try allocator.dupe(u8, gpu_info); } } @@ -71,11 +67,7 @@ pub fn getGPUInfo(allocator: std.mem.Allocator) ![]u8 { var lines = std.mem.splitSequence(u8, glx_output, "\n"); while (lines.next()) |line| { if (std.mem.startsWith(u8, line, "OpenGL renderer string:")) { - const gpu_info = std.mem.trim( - u8, - line["OpenGL renderer string:".len ..], - " " - ); + const gpu_info = std.mem.trim(u8, line["OpenGL renderer string:".len..], " "); return try allocator.dupe(u8, gpu_info); } } @@ -88,11 +80,7 @@ pub fn getGPUInfo(allocator: std.mem.Allocator) ![]u8 { var lines = std.mem.splitSequence(u8, vk_output, "\n"); while (lines.next()) |line| { if (std.mem.indexOf(u8, line, "deviceName")) |idx| { - const gpu_info = std.mem.trim( - u8, - line[idx + "deviceName".len ..], - " :\t" - ); + const gpu_info = std.mem.trim(u8, line[idx + "deviceName".len ..], " :\t"); return try allocator.dupe(u8, gpu_info); } } @@ -109,11 +97,7 @@ pub fn getGPUInfo(allocator: std.mem.Allocator) ![]u8 { const device = try device_file.readToEndAlloc(allocator, 16); defer allocator.free(device); - const combined = try std.fmt.allocPrint( - allocator, - "PCI Vendor: {s}, Device: {s}", - .{ std.mem.trim(u8, vendor, "\n "), std.mem.trim(u8, device, "\n ") } - ); + const combined = try std.fmt.allocPrint(allocator, "PCI Vendor: {s}, Device: {s}", .{ std.mem.trim(u8, vendor, "\n "), std.mem.trim(u8, device, "\n ") }); return combined; } else |_| {} } else |_| {} diff --git a/src/main.zig b/src/main.zig index 345353e..7b3ce55 100644 --- a/src/main.zig +++ b/src/main.zig @@ -58,7 +58,7 @@ pub fn main() !void { const uptime = system.executeUptimeCommand(allocator, &[_][]const u8{ "uptime", "-p" }) catch |err| blk: { // Because NixOS does not have a -p if (err == error.CommandFailed) { - break :blk try system.executeUptimeCommand(allocator, &[_][]const u8{ "uptime" }); + break :blk try system.executeUptimeCommand(allocator, &[_][]const u8{"uptime"}); } else { return err; } diff --git a/src/system.zig b/src/system.zig index 3a8b1e9..1f5f7f9 100644 --- a/src/system.zig +++ b/src/system.zig @@ -121,7 +121,7 @@ pub fn executeCommand(allocator: std.mem.Allocator, argv: []const []const u8) ![ return try result.toOwnedSlice(allocator); } -pub fn executeUptimeCommand(allocator: std.mem.Allocator, argv: []const []const u8) ![] u8 { +pub fn executeUptimeCommand(allocator: std.mem.Allocator, argv: []const []const u8) ![]u8 { var result = std.ArrayListUnmanaged(u8){}; defer result.deinit(allocator); @@ -143,4 +143,3 @@ pub fn executeUptimeCommand(allocator: std.mem.Allocator, argv: []const []const return result.toOwnedSlice(allocator); } - From 6b45660b9f99e20a7c224f8dfb4ce74698a2c539 Mon Sep 17 00:00:00 2001 From: pop-ecx Date: Tue, 13 Jan 2026 09:06:40 +0300 Subject: [PATCH 2/2] ci: zig fmt --- .github/workflows/fmt.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/fmt.yml diff --git a/.github/workflows/fmt.yml b/.github/workflows/fmt.yml new file mode 100644 index 0000000..44f5b83 --- /dev/null +++ b/.github/workflows/fmt.yml @@ -0,0 +1,22 @@ +name: Zig fmt check + +on: + pull_request: + branches: [ "main" ] + +jobs: + zig-fmt: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install Zig + uses: mlugg/setup-zig@v2 + with: + version: 0.15.1 + + - name: Zig fmt check + run: | + zig fmt --check .