~mil/sxmo-utils

ref: 4bf92406d0b7e8e7a4093d1e81d4e4ce4078faee sxmo-utils/programs/sxmo_setpinebacklight.c -rw-r--r-- 949 bytes
4bf92406Stacy Harper Try to make bluetooth menu connection more reliable 9 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

char * pbpScreen = "/sys/class/backlight/edp-backlight/brightness";
char * ppScreen = "/sys/devices/platform/backlight/backlight/backlight/brightness";

void usage() {
	fprintf(stderr, "Usage: sxmo_setpinebacklight [number]\n");
}

void writeFile(char *filepath, int brightness) {
	FILE *f;
	f = fopen(filepath, "w+");
	fprintf(f, "%d\n", brightness);
	fclose(f);
}

int main(int argc, char *argv[]) {
	char * command;
	int brightness;

	if (argc < 2) {
		usage();
		return 1;
	}
	argc--;
	brightness = atoi(argv[argc--]);

	if (access(pbpScreen, F_OK) != -1) {
		writeFile(pbpScreen, brightness);
		fprintf(stderr, "Set PBP brightness to %d\n", brightness);
	} else if (access(ppScreen, F_OK) != -1) {
		writeFile(ppScreen, brightness);
		fprintf(stderr, "Set PP brightness to %d\n", brightness);
	} else {
		fprintf(stderr, "Neither PP or PBP Screen found!\n");
	}
}