495 current 2024-04-28 20:50:10 24.05.20240428.30ddacc 6.8.6-zen1 *
This commit is contained in:
parent
5549a17e4c
commit
d6c181bc5b
46 changed files with 1685 additions and 10 deletions
49
modules/rice/ags/cfg/services/brightness.js
Normal file
49
modules/rice/ags/cfg/services/brightness.js
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import { Service, Utils } from "../imports.js";
|
||||
|
||||
class Brightness extends Service {
|
||||
static {
|
||||
Service.register(
|
||||
this,
|
||||
{},
|
||||
{
|
||||
screen: ["float", "rw"],
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
_screen = 0;
|
||||
|
||||
get screen() {
|
||||
return this._screen;
|
||||
}
|
||||
|
||||
set screen(percent) {
|
||||
if (percent < 0) percent = 0;
|
||||
|
||||
if (percent > 1) percent = 1;
|
||||
|
||||
Utils.execAsync(`brightnessctl s ${percent * 100}% -q`)
|
||||
.then(() => {
|
||||
this._screen = percent;
|
||||
this.changed("screen");
|
||||
})
|
||||
.catch(console.error);
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
try {
|
||||
this._screen =
|
||||
Number(Utils.exec("brightnessctl g")) /
|
||||
Number(Utils.exec("brightnessctl m"));
|
||||
} catch (error) {
|
||||
console.error("missing dependancy: brightnessctl");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const service = new Brightness();
|
||||
|
||||
globalThis.brightness = service;
|
||||
|
||||
export default service;
|
||||
Loading…
Add table
Add a link
Reference in a new issue