Signed-off-by: Stacy Harper <contact@stacyharper.net>master
parent
921ab1773a
commit
d42c4f58d4
2 changed files with 1 additions and 47 deletions
@ -1,40 +0,0 @@ |
|||||||
#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"); |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue