Skip to content
Snippets Groups Projects
Commit ed71df40 authored by JiriKalvoda's avatar JiriKalvoda
Browse files

LIGHT Add support for second graphic card.

parent 77e394dc
No related branches found
No related tags found
No related merge requests found
const int adrlen = 2;
const char adr [adrlen][1000] =
{
"/sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight/brightness",
"/sys/devices/pci0000:00/0000:00:02.0/drm/card1/card1-eDP-1/intel_backlight/brightness"
};
......@@ -3,17 +3,21 @@
#include <sys/types.h>
#include <unistd.h>
#include <math.h>
#include "adr.h"
const char adr [] = "/sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight/brightness";
const int lightMin = 2;
const int lightMax = 937;
int main(int argc,char ** argv)
{
if(argc<2) return 100;
setuid(0);
for(int adri=0;adri<adrlen;adri++)
{
{
if(argv[1][0]=='H')
{
FILE * f = fopen(adr,"w");
FILE * f = fopen(adr[adri],"w");
if(!f) goto nextAdr;
fprintf(f,"%d",atoi(argv[2]));
fclose(f);
return 0;
......@@ -24,7 +28,9 @@ int main(int argc,char ** argv)
light = argv2;
else
{
FILE * f = fopen(adr,"r");
FILE * f = fopen(adr[adri],"r");
if(!f) goto nextAdr;
fprintf(f,"%d",atoi(argv[2]));
int realAct;
fscanf(f,"%d",&realAct);
if(realAct<light) realAct=lightMin;
......@@ -50,7 +56,8 @@ int main(int argc,char ** argv)
notInLimit=1;
}
int intLight = realLight+0.7;
FILE * f = fopen(adr,"w");
FILE * f = fopen(adr[adri],"w");
if(!f) goto nextAdr;
//printf("light=%d\n",intLight);
fprintf(f,"%d",intLight);
fclose(f);
......@@ -59,3 +66,6 @@ int main(int argc,char ** argv)
//system(exe);
return notInLimit;
}
nextAdr:;
}
}
......@@ -3,14 +3,18 @@
#include <sys/types.h>
#include <unistd.h>
#include <math.h>
#include "adr.h"
const char adr [] = "/sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight/brightness";
const int lightMin = 2;
const int lightMax = 937;
int main(int argc,char ** argv)
{
setuid(0);
FILE * f = fopen(adr,"r");
for(int adri=0;adri<adrlen;adri++)
{
{
FILE * f = fopen(adr[adri],"r");
if(!f) goto nextAdr;
int realAct;
fscanf(f,"%d",&realAct);
double act=log(realAct);
......@@ -20,4 +24,10 @@ int main(int argc,char ** argv)
printf("%s",act<i?"−":"+");
printf("]");
fclose(f);
return 0;
}
nextAdr:;
}
return 1;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment