From 23779bdba1759bb10ad2af1d027f1274e4a833a6 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Mon, 17 Feb 2025 12:40:13 +1100 Subject: gpu: fix auto detection --- src/services/gpu.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/services') diff --git a/src/services/gpu.ts b/src/services/gpu.ts index 916a2bc..179f14e 100644 --- a/src/services/gpu.ts +++ b/src/services/gpu.ts @@ -1,4 +1,4 @@ -import { execAsync, Gio, GObject, interval, property, register } from "astal"; +import { execAsync, Gio, GLib, GObject, interval, property, register } from "astal"; import { gpu as config } from "config"; @register({ GTypeName: "Gpu" }) @@ -24,10 +24,12 @@ export default class Gpu extends GObject.Object { } update() { - this.calculateUsage().then(usage => { - this.#usage = usage; - this.notify("usage"); - }); + this.calculateUsage() + .then(usage => { + this.#usage = usage; + this.notify("usage"); + }) + .catch(console.error); } constructor() { @@ -44,7 +46,7 @@ export default class Gpu extends GObject.Object { let info: Gio.FileInfo | undefined | null; while ((info = enumerator?.next_file(null))) { - if (/card[0-9]+/.test(info.get_name())) { + if (GLib.file_test(`/sys/class/drm/${info.get_name()}/device/gpu_busy_percent`, GLib.FileTest.EXISTS)) { this.available = true; break; } -- cgit v1.2.3-freya