~andreafeletto/levee

ref: 687c1d16212671656bb79436df39feb6275e00a3 levee/src/main.zig -rw-r--r-- 1.2 KiB
687c1d16Andrea Feletto add case for battery capacity computation 8 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const std = @import("std");

const fcft = @import("fcft");

const Config = @import("config.zig").Config;
const Loop = @import("event.zig").Loop;
const modules = @import("modules.zig");
const Wayland = @import("wayland.zig").Wayland;

pub const State = struct {
    allocator: std.mem.Allocator,
    config: Config,
    wayland: Wayland,
    loop: Loop,

    battery: modules.Battery,
    backlight: modules.Backlight,
    modules: std.ArrayList(modules.Module),
};

pub fn main() anyerror!void {
    var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
    defer arena.deinit();

    fcft.init(.auto, false, .info);

    // initialization
    var state: State = undefined;
    state.allocator = arena.allocator();
    state.config = try Config.init();
    state.wayland = try Wayland.init(&state);
    state.loop = try Loop.init(&state);

    // modules
    state.modules = std.ArrayList(modules.Module).init(state.allocator);
    state.backlight = try modules.Backlight.init(&state);
    try state.modules.append(state.backlight.module());
    state.battery = try modules.Battery.init(&state);
    try state.modules.append(state.battery.module());

    // wayland
    try state.wayland.registerGlobals();

    // event loop
    try state.loop.run();
}