summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.zig6
-rw-r--r--src/stat.zig8
2 files changed, 12 insertions, 2 deletions
diff --git a/src/main.zig b/src/main.zig
index 8fe11e4..f334b2f 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -14,17 +14,19 @@ pub fn main() !void {
const ram = try stat.ramInfo(allocator);
const hst = try stat.gethst(allocator);
const ge = try stat.GetRam(allocator);
+ const user = try stat.users(allocator);
defer allocator.free(ge);
+ defer allocator.free(user);
defer allocator.free(ram);
defer allocator.free(hst);
defer allocator.free(osd);
defer allocator.free(cpuq);
defer allocator.free(kernel);
const art = artd.logo;
- try stdout.print("{s} Ezfetch\n", .{art[0]});
+ try stdout.print("{s} Ezfetch\n", .{art[0]});
try stdout.print("{s} -----------------\n", .{art[1]});
try stdout.print("{s} Os: {s}\n", .{art[2], osd});
- try stdout.print("{s} Hostname: {s}\n", .{art[3], hst});
+ try stdout.print("{s} User@hostname: {s}@{s}\n", .{art[3], user, hst});
try stdout.print("{s} Kernel: {s}\n", .{art[4], kernel});
try stdout.print("{s} Cpu: {s}\n", .{art[5], cpuq});
try stdout.print(" Ram: {s} / {s} \n", .{ge, ram});
diff --git a/src/stat.zig b/src/stat.zig
index 928bce7..3568704 100644
--- a/src/stat.zig
+++ b/src/stat.zig
@@ -121,3 +121,11 @@ var buf: [1024]u8 = undefined;
const used_gb = (total_kb - available_kb) / (1024.0 * 1024.0);
return std.fmt.allocPrint(allocator, "{d:.2}", .{used_gb});
}
+ pub fn users(allocator: std.mem.Allocator) ![]const u8 {
+
+ if (std.process.getEnvVarOwned(allocator, "USER")) |username| {
+ return username;
+ } else |_| {
+ return try allocator.dupe(u8, "user");
+ }
+ }