gpu: fix auto detection
This commit is contained in:
parent
354c3446de
commit
23779bdba1
1 changed files with 8 additions and 6 deletions
|
|
@ -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";
|
import { gpu as config } from "config";
|
||||||
|
|
||||||
@register({ GTypeName: "Gpu" })
|
@register({ GTypeName: "Gpu" })
|
||||||
|
|
@ -24,10 +24,12 @@ export default class Gpu extends GObject.Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
update() {
|
update() {
|
||||||
this.calculateUsage().then(usage => {
|
this.calculateUsage()
|
||||||
|
.then(usage => {
|
||||||
this.#usage = usage;
|
this.#usage = usage;
|
||||||
this.notify("usage");
|
this.notify("usage");
|
||||||
});
|
})
|
||||||
|
.catch(console.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
@ -44,7 +46,7 @@ export default class Gpu extends GObject.Object {
|
||||||
|
|
||||||
let info: Gio.FileInfo | undefined | null;
|
let info: Gio.FileInfo | undefined | null;
|
||||||
while ((info = enumerator?.next_file(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;
|
this.available = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue