~andreafeletto/cstatus

007ca76b8d25f8aeda9892fe558a47b72e24ed69 — Andrea Feletto a month ago 969aaa1
refactor screen brightness config
2 files changed, 6 insertions(+), 6 deletions(-)

M backlight.c
M backlight.h
M backlight.c => backlight.c +4 -4
@@ 13,16 13,16 @@ backlight(char *buf) {
	FILE *fp;
	int b, mb, p;

	if ((fp = fopen(BLBRIGH, "r")) == NULL) {
		fprintf(stderr, "cannot open file '%s'\n", BLBRIGH);
	if ((fp = fopen(BRIGHT_VALUE, "r")) == NULL) {
		fprintf(stderr, "cannot open file '%s'\n", BRIGHT_VALUE);
	}
	if (fscanf(fp, "%d", &b) != 1) {
		fputs("cannot read brightness value\n", stderr);
	}
	fclose(fp);

	if ((fp = fopen(BLMAX, "r")) == NULL) {
		fprintf(stderr, "cannot open file '%s'\n", BLMAX);
	if ((fp = fopen(BRIGHT_MAX_VALUE, "r")) == NULL) {
		fprintf(stderr, "cannot open file '%s'\n", BRIGHT_MAX_VALUE);
	}
	if (fscanf(fp, "%d", &mb) != 1) {
		fputs("cannot read max brightness value\n", stderr);

M backlight.h => backlight.h +2 -2
@@ 3,10 3,10 @@
#define CSTATUS_BACKLIGHT_H

/* path of file containing screen brightness */
#define BLBRIGH  "/sys/class/backlight/intel_backlight/brightness"
#define BRIGHT_VALUE "/sys/class/backlight/intel_backlight/brightness"

/* path of file containing max screen brightness */
#define BLMAX    "/sys/class/backlight/intel_backlight/max_brightness"
#define BRIGHT_MAX_VALUE "/sys/class/backlight/intel_backlight/max_brightness"

int backlight(char *buf);