From ea652045bb38651d99bcc53972a524f602c3b306 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sat, 14 Jul 2018 11:46:12 +0800 Subject: Added a simple tool to create a fake sysfs backlight interface that invokes external commands. Some changes in the utility module to accomodate the new tool. Added an option to watch ALS readings. --- tools/fakebl.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 tools/fakebl.c (limited to 'tools') diff --git a/tools/fakebl.c b/tools/fakebl.c new file mode 100644 index 0000000..dc2d9b9 --- /dev/null +++ b/tools/fakebl.c @@ -0,0 +1,74 @@ +#include +#include +#include +#include +#include +#include +char *path; +char *brpath; +char *mbrpath; +char *cmd; +char *rcmd; +FILE *brf; +int setup_dir() +{ + int r=mkdir(path,0755); + brpath=malloc(strlen(path)+12); + mbrpath=malloc(strlen(path)+16); + strcpy(brpath,path); + strcpy(mbrpath,path); + strcat(brpath,"/brightness"); + strcat(mbrpath,"/max_brightness"); + r|=mkfifo(brpath,0666); + FILE* mbrf=fopen(mbrpath,"w"); + r|=(mbrf==NULL); + if(mbrf)fputs("100\n",mbrf); + fclose(mbrf); + return r; +} +void remove_dir() +{ + unlink(brpath); + unlink(mbrpath); + rmdir(path); + free(brpath); + free(mbrpath); +} +void usage(char* s) +{ + printf("usage: %s -c -p \n",s); + _exit(1); +} +int main(int argc,char **argv) +{ + if(argc<5)usage(argv[0]); + for(int i=1;i