InfoBroker: Add cpu_live

This commit is contained in:
Starbeamrainbowlabs 2022-02-26 19:19:36 +00:00
parent e99ebc9732
commit 67a235ad42
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -13,11 +13,16 @@ const __dirname = import.meta.url.slice(7, import.meta.url.lastIndexOf("/"));
class InfoBroker {
constructor() {
this.sym_meta = Symbol("____meta_info____")
this.allowed_tables = {
// name → sysinfo name
cpu: "cpu",
meta: this.sym_meta
cpu_live: async () => {
return {
frequency: await sysinfo.cpuCurrentSpeed(),
temperature: await sysinfo.cpuTemperature()
};
},
meta: async () => await this.make_table_meta()
};
}
@ -45,8 +50,9 @@ class InfoBroker {
}
let name_translated = this.allowed_tables[name];
if(name_translated === this.sym_meta)
return await this.make_table_meta();
if(typeof name_translated === "function")
return await name_translated();
return await sysinfo[name_translated]();
}