Add compile options and change light.c
This commit is contained in:
parent
d0853dd731
commit
4a6d097f9e
2 changed files with 9 additions and 8 deletions
4
Makefile
4
Makefile
|
@ -1,5 +1,7 @@
|
||||||
|
CFLAGS = -lm -ansi -static -s -Ofast -march=native
|
||||||
|
|
||||||
light: light.c
|
light: light.c
|
||||||
$(CC) light.c $(CFLAGS) -lm -o light
|
$(CC) light.c $(CFLAGS) -o light
|
||||||
|
|
||||||
install: light
|
install: light
|
||||||
install light /usr/local/bin
|
install light /usr/local/bin
|
||||||
|
|
13
light.c
13
light.c
|
@ -3,8 +3,10 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#define BRIGHTNESS "/sys/class/backlight/amdgpu_bl1/brightness"
|
#define PREFIX "/sys/class/backlight/amdgpu_bl0/"
|
||||||
#define MAX_BRIGHTNESS "/sys/class/backlight/amdgpu_bl1/max_brightness"
|
|
||||||
|
#define BRIGHTNESS PREFIX "brightness"
|
||||||
|
#define MAX_BRIGHTNESS PREFIX "max_brightness"
|
||||||
|
|
||||||
int brightness;
|
int brightness;
|
||||||
char brightness_str[8];
|
char brightness_str[8];
|
||||||
|
@ -23,11 +25,8 @@ int main(int argc, char* argv[])
|
||||||
brightness_fp = fopen(BRIGHTNESS, "w+");
|
brightness_fp = fopen(BRIGHTNESS, "w+");
|
||||||
max_brightness_fp = fopen(MAX_BRIGHTNESS, "r");
|
max_brightness_fp = fopen(MAX_BRIGHTNESS, "r");
|
||||||
|
|
||||||
fgets(brightness_str, 8, brightness_fp);
|
brightness = atoi(fgets(brightness_str, 8, brightness_fp));
|
||||||
brightness = atoi(brightness_str);
|
max_brightness = atoi(fgets(max_brightness_str, 8, max_brightness_fp));
|
||||||
|
|
||||||
fgets(max_brightness_str, 8, max_brightness_fp);
|
|
||||||
max_brightness = atoi(max_brightness_str);
|
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
char *arg = argv[1];
|
char *arg = argv[1];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue