aboutsummaryrefslogtreecommitdiff
path: root/.config/ags/service/brightness.ts
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2025-08-30 19:22:59 +0200
committersrdusr <trevorgray@srdusr.com>2025-08-30 19:22:59 +0200
commit19120d4f9761c67d99ed1ce3da6084b83f5a49c9 (patch)
treef234cad1bdad88114a63c9702144da487024967a /.config/ags/service/brightness.ts
parent5928998af5404ae2be84c6cecc10ebf84bd3f3ed (diff)
downloaddotfiles-19120d4f9761c67d99ed1ce3da6084b83f5a49c9.tar.gz
dotfiles-19120d4f9761c67d99ed1ce3da6084b83f5a49c9.zip
Linux-specific dotfiles
Diffstat (limited to '.config/ags/service/brightness.ts')
-rw-r--r--.config/ags/service/brightness.ts69
1 files changed, 0 insertions, 69 deletions
diff --git a/.config/ags/service/brightness.ts b/.config/ags/service/brightness.ts
deleted file mode 100644
index a0b8eb5..0000000
--- a/.config/ags/service/brightness.ts
+++ /dev/null
@@ -1,69 +0,0 @@
-import { bash, dependencies, sh } from "lib/utils"
-
-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`
-
-class Brightness extends Service {
- static {
- Service.register(this, {}, {
- "screen": ["float", "rw"],
- "kbd": ["int", "rw"],
- })
- }
-
- #kbdMax = get(`--device ${kbd} max`)
- #kbd = get(`--device ${kbd} get`)
- #screenMax = get("max")
- #screen = get("get") / get("max")
-
- get kbd() { return this.#kbd }
- get screen() { return this.#screen }
-
- set kbd(value) {
- if (value < 0 || value > this.#kbdMax)
- return
-
- sh(`brightnessctl -d ${kbd} s ${value} -q`).then(() => {
- this.#kbd = value
- this.changed("kbd")
- })
- }
-
- set screen(percent) {
- if (percent < 0)
- percent = 0
-
- if (percent > 1)
- percent = 1
-
- sh(`brightnessctl set ${Math.floor(percent * 100)}% -q`).then(() => {
- this.#screen = percent
- this.changed("screen")
- })
- }
-
- constructor() {
- super()
-
- 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(kbdPath, async f => {
- const v = await Utils.readFileAsync(f)
- this.#kbd = Number(v) / this.#kbdMax
- this.changed("kbd")
- })
- }
-}
-
-export default new Brightness