diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-04-26 22:36:23 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-04-26 22:36:23 +1000 |
| commit | 3c579d0e275cdaf6f2c9589abade94bde7905c82 (patch) | |
| tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /src/services/cpu.ts | |
| parent | schemes: fix (diff) | |
| download | caelestia-shell-3c579d0e275cdaf6f2c9589abade94bde7905c82.tar.gz caelestia-shell-3c579d0e275cdaf6f2c9589abade94bde7905c82.tar.bz2 caelestia-shell-3c579d0e275cdaf6f2c9589abade94bde7905c82.zip | |
clean
Remove everything
Diffstat (limited to 'src/services/cpu.ts')
| -rw-r--r-- | src/services/cpu.ts | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/src/services/cpu.ts b/src/services/cpu.ts deleted file mode 100644 index 5f80d11..0000000 --- a/src/services/cpu.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { GObject, interval, property, register } from "astal"; -import { cpu as config } from "config"; -import GTop from "gi://GTop"; - -@register({ GTypeName: "Cpu" }) -export default class Cpu extends GObject.Object { - static instance: Cpu; - static get_default() { - if (!this.instance) this.instance = new Cpu(); - - return this.instance; - } - - #previous: GTop.glibtop_cpu = new GTop.glibtop_cpu(); - #usage: number = 0; - - @property(Number) - get usage() { - return this.#usage; - } - - calculateUsage() { - const current = new GTop.glibtop_cpu(); - GTop.glibtop_get_cpu(current); - - // Calculate the differences from the previous to current data - const total = current.total - this.#previous.total; - const idle = current.idle - this.#previous.idle; - - this.#previous = current; - - return total > 0 ? ((total - idle) / total) * 100 : 0; - } - - update() { - this.#usage = this.calculateUsage(); - this.notify("usage"); - } - - constructor() { - super(); - - let source = interval(config.interval.get(), () => this.update()); - config.interval.subscribe(i => { - source.cancel(); - source = interval(i, () => this.update()); - }); - } -} |