feat(formatters): add window manager formatters
This commit is contained in:
@@ -20,6 +20,7 @@ pub const formatters = [_]*const fn (allocator: std.mem.Allocator, key: []const
|
||||
&getFormattedSwapInfo,
|
||||
&getFormattedDiskInfo,
|
||||
&getFormattedNetInfo,
|
||||
&getFormattedWindowManagerInfo,
|
||||
&getFormattedTerminalNameInfo,
|
||||
&getFormattedLocaleInfo,
|
||||
&getFormattedCustom,
|
||||
@@ -37,6 +38,7 @@ pub const default_formatters = [_]*const fn (allocator: std.mem.Allocator) anyer
|
||||
&getDefaultFormattedSwapInfo,
|
||||
&getDefaultFormattedDiskInfo,
|
||||
&getDefaultFormattedNetInfo,
|
||||
&getDefaultFormattedWindowManagerInfo,
|
||||
&getDefaultFormattedTerminalNameInfo,
|
||||
&getDefaultFormattedLocaleInfo,
|
||||
};
|
||||
@@ -192,6 +194,16 @@ pub fn getFormattedDiskInfo(allocator: std.mem.Allocator, key: []const u8, key_c
|
||||
return Result{ .string = try std.fmt.allocPrint(allocator, "{s}{s} ({s}):{s} {d:.2} / {d:.2} GB ({}%)", .{ key_color, key, disk_info.disk_path, ascii.Reset, disk_info.disk_usage, disk_info.disk_size, disk_info.disk_usage_percentage }) };
|
||||
}
|
||||
|
||||
pub fn getDefaultFormattedWindowManagerInfo(allocator: std.mem.Allocator) !Result {
|
||||
return try getFormattedWindowManagerInfo(allocator, "WM", ascii.Yellow);
|
||||
}
|
||||
|
||||
pub fn getFormattedWindowManagerInfo(allocator: std.mem.Allocator, key: []const u8, key_color: []const u8) !Result {
|
||||
const wm = try detection.system.getWindowManagerInfo(allocator);
|
||||
defer allocator.free(wm);
|
||||
return Result{ .string = try std.fmt.allocPrint(allocator, "{s}{s}:{s} {s}", .{ key_color, key, ascii.Reset, wm }) };
|
||||
}
|
||||
|
||||
pub fn getDefaultFormattedTerminalNameInfo(allocator: std.mem.Allocator) !Result {
|
||||
return try getFormattedTerminalNameInfo(allocator, "Terminal", ascii.Yellow);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user