aboutsummaryrefslogtreecommitdiff
path: root/linux/home/.config/xob/manage-brightness
blob: 496900fa5cd372ecfdc1a11259aba6b21f7d877d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/node

const fs = require('fs')
const { exec } = require("child_process");

let device = "intel_backlight";

brightnessFile = `/sys/class/backlight/${device}/brightness`;
maxBrightnessFile = `/sys/class/backlight/${device}/max_brightness`;

maxValue = parseInt(fs.readFileSync(maxBrightnessFile, 'utf8'));

fs.watch(brightnessFile, () => {
  value = parseInt(fs.readFileSync(brightnessFile, 'utf8'));
  console.log(Math.round(value / maxValue * 100));
})