Split main() up by adding parseArgs() and run()

parseArgs() contains all of the argument parsing logic in a single fn.

run() handles the event loop. To work with the bar, I had to re-write
the loop to use polling similar to the loop in `beanclock` instead of
just `while (true) dispatch`.
This commit is contained in:
Ben Buhse 2026-02-13 11:10:42 -06:00
commit 5501ccbe26
No known key found for this signature in database
GPG key ID: 7916ACFCD38FD0B4
3 changed files with 125 additions and 48 deletions

View file

@ -114,7 +114,6 @@ pub fn layerSurfaceListener(
bar.configured = true;
log.debug("bwbuhse before render", .{});
bar.render() catch |err| {
log.err("Bar render failed: {}", .{err});
};
@ -125,7 +124,9 @@ pub fn layerSurfaceListener(
}
}
fn render(bar: *Bar) !void {
// TODO: Configure number of visible tags
/// Renders the bar and its components
pub fn render(bar: *Bar) !void {
const buffer = try bar.context.buffer_pool.nextBuffer(bar.context.wl_shm, bar.width, bar.height);
// Fill with a solid color (e.g., dark background)
@ -138,7 +139,6 @@ fn render(bar: *Bar) !void {
wl_surface.attach(buffer.wl_buffer, 0, 0);
wl_surface.damageBuffer(0, 0, bar.width, bar.height);
wl_surface.commit();
log.debug("bwbuhse end of render", .{});
}
// Borrowed and modified from https://git.sr.ht/~novakane/zig-fcft-example