From 7fdcd7feee128ce1db9a95f89a40154784be3c69 Mon Sep 17 00:00:00 2001 From: retrozinndev Date: Fri, 18 Apr 2025 21:41:21 -0300 Subject: [PATCH] :boom: ags(nightlight, control-center/nightlight): fixed wrong fidelity temperature value (10000 changed to 6000) --- ags/scripts/nightlight.ts | 23 ++++++++++++------- ags/widget/control-center/tiles/NightLight.ts | 5 ++-- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/ags/scripts/nightlight.ts b/ags/scripts/nightlight.ts index 275e659..64c2484 100644 --- a/ags/scripts/nightlight.ts +++ b/ags/scripts/nightlight.ts @@ -37,7 +37,7 @@ class NightLight extends GObject.Object { constructor() { super(); - this.#watchInterval = interval(500, () => { + this.#watchInterval = interval(1000, () => { execAsync("hyprctl hyprsunset temperature").then(t => { if(t.trim() !== "" && t.trim().length <= 5) { const val = Number.parseInt(t.trim()); @@ -80,6 +80,10 @@ class NightLight extends GObject.Object { execAsync(`hyprctl hyprsunset temperature ${value}`).then(() => { this.#temperature = value; this.notify("temperature"); + + this.#identity = false; + this.#prevTemperature = null; + this.#prevGamma = null; }).catch((r) => console.error( `Night Light(hyprsunset): Couldn't set temperature. Stderr: ${r}` )); @@ -97,6 +101,10 @@ class NightLight extends GObject.Object { execAsync(`hyprctl hyprsunset gamma ${value}`).then(() => { this.#gamma = value; this.notify("gamma"); + + this.#identity = false; + this.#prevTemperature = null; + this.#prevGamma = null; }).catch((r) => console.error( `Night Light(hyprsunset): Couldn't set gamma. Stderr: ${r}` )); @@ -108,13 +116,9 @@ class NightLight extends GObject.Object { this.#prevGamma = this.#gamma; this.#prevTemperature = this.#temperature; - execAsync("hyprctl hyprsunset identity").then(() => { - this.#identity = true; - this.temperature = 10000; - this.gamma = this.maxGamma; - }).catch((r) => console.error( - `Night Light(hyprsunset): Couldn't set filters to identity(no filters). Stderr: ${r}` - )); + this.#identity = true; + this.temperature = 6000; + this.gamma = this.maxGamma; } public filter(): void { @@ -123,5 +127,8 @@ class NightLight extends GObject.Object { this.#identity = false; this.setTemperature(this.#prevTemperature ?? 1000); this.setGamma(this.#prevGamma ?? 100); + + this.#prevTemperature = null; + this.#prevGamma = null; } } diff --git a/ags/widget/control-center/tiles/NightLight.ts b/ags/widget/control-center/tiles/NightLight.ts index 93fd678..f28050d 100644 --- a/ags/widget/control-center/tiles/NightLight.ts +++ b/ags/widget/control-center/tiles/NightLight.ts @@ -12,7 +12,7 @@ export const TileNightLight = Tile({ bind(NightLight.getDefault(), "temperature"), bind(NightLight.getDefault(), "gamma") ], (temp, gamma) => - (temp === 10000 ? tr("control_center.tiles.night_light.default_desc") + (temp === 6000 ? tr("control_center.tiles.night_light.default_desc") : `${temp}K`) + (gamma < NightLight.getDefault().maxGamma ? ` (${gamma}%)` : "") )(), @@ -21,6 +21,5 @@ export const TileNightLight = Tile({ onToggledOn: () => NightLight.getDefault().identity = false, enableOnClickMore: true, onClickMore: () => togglePage(PageNightLight), - toggleState: bind(NightLight.getDefault(), "identity").as(identity => - identity ? false : true) + toggleState: bind(NightLight.getDefault(), "identity").as(identity => !identity) } as TileProps);