Xinqi Bao's Git
1 /* See LICENSE file for copyright and license details. */
7 #define BRIGHTNESS_MAX "/sys/class/backlight/%s/max_brightness"
8 #define BRIGHTNESS_CUR "/sys/class/backlight/%s/brightness"
11 backlight_perc(const char *card
)
16 if (esnprintf(path
, sizeof (path
), BRIGHTNESS_MAX
, card
) < 0 ||
17 pscanf(path
, "%d", &max
) != 1) {
21 if (esnprintf(path
, sizeof (path
), BRIGHTNESS_CUR
, card
) < 0 ||
22 pscanf(path
, "%d", &cur
) != 1) {
30 return bprintf("%d", cur
* 100 / max
);