Add single_window_ratio to Bar when != 1
This adds single window ratio's percent after the primary ratio into the bar, but only when the ratio isn't 1 (so, on small screens where people are using 100% of the output for windows, it won't be there).
This commit is contained in:
parent
63f5fc1bcd
commit
2f29434af0
2 changed files with 12 additions and 7 deletions
16
src/Bar.zig
16
src/Bar.zig
|
|
@ -260,13 +260,15 @@ fn draw(bar: *Bar) !void {
|
||||||
const output = bar.output;
|
const output = bar.output;
|
||||||
var wm_info_buf: [255:0]u8 = undefined;
|
var wm_info_buf: [255:0]u8 = undefined;
|
||||||
var wm_info_writer = Io.Writer.fixed(&wm_info_buf);
|
var wm_info_writer = Io.Writer.fixed(&wm_info_buf);
|
||||||
const ratio_percent: u32 = @intFromFloat(@round(output.primary_ratio * 100));
|
const primary_ratio_percent: u32 = @intFromFloat(@round(output.primary_ratio * 100));
|
||||||
try wm_info_writer.print("P:{d}/{d}% W:{d}({d})", .{
|
try wm_info_writer.print("P:{d}/{d}%", .{ output.primary_count, primary_ratio_percent });
|
||||||
output.primary_count,
|
if (output.single_window_ratio != 1) {
|
||||||
ratio_percent,
|
const single_window_ratio_percent: u32 = @intFromFloat(@round(output.single_window_ratio * 100));
|
||||||
output.countVisible(),
|
try wm_info_writer.print("({d}%)", .{single_window_ratio_percent});
|
||||||
output.windows.length(),
|
}
|
||||||
});
|
try wm_info_writer.print(" W:{d}({d})", .{ output.countVisible(), output.windows.length() });
|
||||||
|
try wm_info_writer.flush();
|
||||||
|
|
||||||
const wm_info_codepoints = try utils.utf8ToCodepoints(wm_info_writer.buffered());
|
const wm_info_codepoints = try utils.utf8ToCodepoints(wm_info_writer.buffered());
|
||||||
defer utils.gpa.free(wm_info_codepoints);
|
defer utils.gpa.free(wm_info_codepoints);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -340,6 +340,9 @@ pub fn manage(output: *Output) void {
|
||||||
Config.min_primary_ratio,
|
Config.min_primary_ratio,
|
||||||
1.00,
|
1.00,
|
||||||
);
|
);
|
||||||
|
if (output.bar) |*bar| {
|
||||||
|
bar.pending_render.draw = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output.pending_manage.tags) |new_tags| {
|
if (output.pending_manage.tags) |new_tags| {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue