~andreafeletto/levee

ref: 485b6cb9f94ffd7c7a057b3a7fc0bbb9460b2932 levee/src/main.zig -rw-r--r-- 1.1 KiB
485b6cb9Andrea Feletto make module creation dynamic 2 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
const std = @import("std");
const heap = std.heap;
const mem = std.mem;

const fcft = @import("fcft");

const Config = @import("Config.zig");
const Loop = @import("Loop.zig");
const Modules = @import("Modules.zig");
const Wayland = @import("wayland.zig").Wayland;

pub const State = struct {
    gpa: mem.Allocator,
    config: Config,
    wayland: Wayland,
    modules: Modules,
    loop: Loop,
};

pub fn main() anyerror!void {
    var gpa: heap.GeneralPurposeAllocator(.{}) = .{};
    defer _ = gpa.deinit();

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

    // initialization
    var state: State = undefined;
    state.gpa = gpa.allocator();
    state.config = try Config.init();
    state.wayland = try Wayland.init(&state);
    defer state.wayland.deinit();
    state.modules = Modules.init(&state);
    defer state.modules.deinit();
    state.loop = try Loop.init(&state);

    // modules
    try state.modules.register(Modules.Alsa);
    try state.modules.register(Modules.Backlight);
    try state.modules.register(Modules.Battery);

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