Implemented strict linting standards and prettier formatting config. (#248)

* Implemented strict linting standards and prettier formatting config.

* More linter fixes and type updates.

* More linter updates and type fixes

* Remove noisy comments

* Linter and type updates

* Linter, formatting and type updates.

* Linter updates

* Type updates

* Type updates

* fixed all linter errors

* Fixed all linting, formatting and type issues.

* Resolve merge conflicts.
This commit is contained in:
Jas Singh
2024-09-14 16:20:05 -07:00
committed by GitHub
parent ff13e3dd3c
commit 2c72cc66d8
222 changed files with 13141 additions and 8433 deletions

View File

@@ -1,70 +1,74 @@
// <3 Aylur for this brightness service
import { bash, dependencies, sh } from "lib/utils"
import { bash, dependencies, sh } from 'lib/utils';
if (!dependencies("brightnessctl"))
App.quit()
if (!dependencies('brightnessctl')) App.quit();
const get = (args: string) => Number(Utils.exec(`brightnessctl ${args}`))
const screen = await bash`ls -w1 /sys/class/backlight | head -1`
const kbd = await bash`ls -w1 /sys/class/leds | head -1`
const get = (args: string): number => Number(Utils.exec(`brightnessctl ${args}`));
const screen = await bash`ls -w1 /sys/class/backlight | head -1`;
const kbd = await bash`ls -w1 /sys/class/leds | head -1`;
class Brightness extends Service {
static {
Service.register(this, {}, {
"screen": ["float", "rw"],
"kbd": ["int", "rw"],
})
Service.register(
this,
{},
{
screen: ['float', 'rw'],
kbd: ['int', 'rw'],
},
);
}
#kbdMax = get(`--device ${kbd} max`)
#kbd = get(`--device ${kbd} get`)
#screenMax = get(`--device ${screen} max`)
#screen = get(`--device ${screen} get`) / (get(`--device ${screen} max`) || 1)
#kbdMax = get(`--device ${kbd} max`);
#kbd = get(`--device ${kbd} get`);
#screenMax = get(`--device ${screen} max`);
#screen = get(`--device ${screen} get`) / (get(`--device ${screen} max`) || 1);
get kbd() { return this.#kbd }
get screen() { return this.#screen }
get kbd(): number {
return this.#kbd;
}
get screen(): number {
return this.#screen;
}
set kbd(value) {
if (value < 0 || value > this.#kbdMax)
return
if (value < 0 || value > this.#kbdMax) return;
sh(`brightnessctl -d ${kbd} s ${value} -q`).then(() => {
this.#kbd = value
this.changed("kbd")
})
this.#kbd = value;
this.changed('kbd');
});
}
set screen(percent) {
if (percent < 0)
percent = 0
if (percent < 0) percent = 0;
if (percent > 1)
percent = 1
if (percent > 1) percent = 1;
sh(`brightnessctl set ${Math.round(percent * 100)}% -d ${screen} -q`).then(() => {
this.#screen = percent
this.changed("screen")
})
this.#screen = percent;
this.changed('screen');
});
}
constructor() {
super()
super();
const screenPath = `/sys/class/backlight/${screen}/brightness`
const kbdPath = `/sys/class/leds/${kbd}/brightness`
const screenPath = `/sys/class/backlight/${screen}/brightness`;
const kbdPath = `/sys/class/leds/${kbd}/brightness`;
Utils.monitorFile(screenPath, async f => {
const v = await Utils.readFileAsync(f)
this.#screen = Number(v) / this.#screenMax
this.changed("screen")
})
Utils.monitorFile(screenPath, async (f) => {
const v = await Utils.readFileAsync(f);
this.#screen = Number(v) / this.#screenMax;
this.changed('screen');
});
Utils.monitorFile(kbdPath, async f => {
const v = await Utils.readFileAsync(f)
this.#kbd = Number(v) / this.#kbdMax
this.changed("kbd")
})
Utils.monitorFile(kbdPath, async (f) => {
const v = await Utils.readFileAsync(f);
this.#kbd = Number(v) / this.#kbdMax;
this.changed('kbd');
});
}
}
export default new Brightness
export default new Brightness();