From 47152e728b1ef40c4f31f3619e9a1902a6ddc25e Mon Sep 17 00:00:00 2001 From: retrozinndev Date: Wed, 27 Aug 2025 14:18:33 -0300 Subject: [PATCH] :wrench: chore(modules/backlight): init default backlight on scan() --- src/modules/backlight.ts | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/modules/backlight.ts b/src/modules/backlight.ts index 0d12a20..e54959b 100644 --- a/src/modules/backlight.ts +++ b/src/modules/backlight.ts @@ -57,14 +57,26 @@ export namespace Backlights { return []; } - if(backlights.length < 1 && this.#available === true) { - this.#available = false; - this.notify("available"); + if(backlights.length < 1) { + if(this.#available) { + this.#available = false; + this.notify("available"); + } + + this.#default = null; + this.notify("default"); } - if(this.#backlights.length < 1 && backlights.length > 0) { - this.#available = true; - this.notify("available"); + if(backlights.length > 0) { + if(this.#backlights.length < 1) { + this.#available = true; + this.notify("available"); + } + + if(!this.#default || !backlights.filter(bk => bk.path === this.#default?.path)[0]) { + this.#default = backlights[0]; + this.notify("default"); + } } this.#backlights = backlights; @@ -91,6 +103,9 @@ export namespace Backlights { }, this); } public static $gtype: GObject.GType; + declare $signals: GObject.Object.SignalSignatures & { + "brightness-changed": (value: number) => void + }; readonly #name: string; #path: string; @@ -125,10 +140,6 @@ export namespace Backlights { get maxBrightness() { return this.#maxBrightness;}; - declare $signals: GObject.Object.SignalSignatures & { - "brightness-changed": (value: number) => void - }; - // intel_backlight is mostly the default on laptops constructor(name: string = "intel_backlight") { super();