diff options
| author | Julian Hurst <julian.hurst@digdash.com> | 2024-10-23 16:50:55 +0200 |
|---|---|---|
| committer | Julian Hurst <julian.hurst@digdash.com> | 2024-10-23 16:50:55 +0200 |
| commit | 68b7830d5b20653d2335037814ee94e6f4fd495d (patch) | |
| tree | 9d0d9959d1a6db58781184f5bee3b687a5144835 /cmd | |
| parent | 31cd2a3450eafbe0d22af41449276a90ea3dcb28 (diff) | |
| download | statusdaemon-68b7830d5b20653d2335037814ee94e6f4fd495d.tar.gz | |
WIP: Add disk space support
Currently disk space is wrong due to it using stat and reading the size
of the folder (4096). Need to use smth like statvfs somehow...
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/statusdaemon/main.ha | 29 |
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( |
