summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/statusdaemon/main.ha29
1 files changed, 26 insertions, 3 deletions
diff --git a/cmd/statusdaemon/main.ha b/cmd/statusdaemon/main.ha
index 1356d32..63adac7 100644
--- a/cmd/statusdaemon/main.ha
+++ b/cmd/statusdaemon/main.ha
@@ -35,6 +35,7 @@ type status = struct {
clock: clock,
host: hostname,
generics: []generic,
+ disk: disk,
};
type section = struct {
@@ -80,10 +81,14 @@ export fn main() void = {
...
};
- const clocktimer = ev::newtimer(&loop, &clocktimerf, time::clock::MONOTONIC)!;
- ev::timer_configure(clocktimer, 1 * time::SECOND, 1 * time::SECOND);
+ const timer = ev::newtimer(&loop, &nativetimerf, time::clock::MONOTONIC)!;
+ ev::timer_configure(timer, 1 * time::SECOND, 1 * time::SECOND);
+ ev::setuser(timer, &state);
+
+ //const alltimer = ev::newtimer(&loop, &alltimerf, time::clock::MONOTONIC)!;
+ //ev::timer_configure(alltimer, 10 * time::SECOND, 10 * time::SECOND);
+ //ev::setuser(alltimer, &state);
- ev::setuser(clocktimer, &state);
ev::setuser(sock, &state);
ev::accept(sock, &accept);
@@ -103,6 +108,7 @@ fn newstatus() (status | io::error | utf8::invalid) = {
generics = alloc([
buildgeneric("/home/jhurst/.local/share/statusbar/vol.sh"),
]),
+ disk = builddisk("/"),
};
};
@@ -112,6 +118,22 @@ fn finishstatus(status: *status) void = {
finishgeneric(gen);
};
free(status.generics);
+ finishdisk(&status.disk);
+};
+
+fn alltimerf(file: *ev::file) void = {
+ let server = ev::getuser(file): *server;
+ for (let gen &.. server.status.generics) {
+ updategeneric(gen)!;
+ };
+ printstatus(server.status);
+};
+
+fn nativetimerf(file: *ev::file) void = {
+ let server = ev::getuser(file): *server;
+ updateclock(&server.status.clock)!;
+ updatedisk(&server.status.disk);
+ printstatus(server.status);
};
fn buildhostname() hostname = {
@@ -140,6 +162,7 @@ fn getstatus(state: *status) str = {
};
memio::concat(&st,
state.host.section.label, state.host.value, " | ",
+ state.disk.section.label, state.disk.value, " | ",
state.clock.section.label, state.clock.value, "\n"
)!;
//const s = strings::concat(