#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