feat: monitor brightness control

This commit is contained in:
2024-01-09 00:50:50 +01:00
parent 5b1d5b06ff
commit d44992db17
3 changed files with 11 additions and 4 deletions

View File

@@ -42,13 +42,18 @@ class Brightness extends Service {
}
set screen(percent) {
if (!dependencies(["brightnessctl"])) return;
if (!dependencies(["gbmonctl"])) return;
if (percent < 0) percent = 0;
if (percent > 1) percent = 1;
Utils.execAsync(`brightnessctl s ${percent * 100}% -q`)
Utils.execAsync(
`gbmonctl --prop brightness -val ${Math.min(
Math.max(Math.floor(percent * 100), 0),
100,
)}`,
)
.then(() => {
this.#screen = percent;
this.changed("screen");