-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscreen_brightness.c
More file actions
59 lines (44 loc) · 1.45 KB
/
screen_brightness.c
File metadata and controls
59 lines (44 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//yum -y install xrandr//
#include<stdio.h>
#include <string.h>
int getscreenstatus()
{
// FILE *screen_verbose;
// screen_verbose = popen("xrandr | grep -v disconnected > string ./screen_verbose.txt", "w");
// pclose(screen_verbose);
FILE *screen_chose;
screen_chose = popen("xrandr | grep -v disconnected | grep connected | cut -d ' ' -f1 > ./screenDEV_chose.txt", "w");
pclose(screen_chose);
return 0;
}
int main()
{
int CHANGE_SCREEN_BRIGHTNESS;
scanf("%d",&CHANGE_SCREEN_BRIGHTNESS);
double brightness_value = CHANGE_SCREEN_BRIGHTNESS / 100.00;
char itoc_CHANGE_SCREEN_BRIGHTNESS[20];
sprintf(itoc_CHANGE_SCREEN_BRIGHTNESS, "%.2f", brightness_value);
getscreenstatus();
freopen("./screenDEV_chose.txt","r",stdin);
char dev[300] = "\0";
while (scanf("%s", dev) != EOF)
puts(dev);
//printf("%s", dev);
char *first = "xrandr --output ";
char *second = " --brightness ";
//char *screenBrightness = "0.4"; //GET THE INPUT//
char command[100] = "\0";
strcat(command, first);
strcat(command, dev);
strcat(command, second);
strcat(command, itoc_CHANGE_SCREEN_BRIGHTNESS);
printf("%s\n",command);
FILE *BRIGHTNESS;
BRIGHTNESS = popen(command, "w");
fclose(stdin);
pclose(BRIGHTNESS);
FILE *rm_screen_chose;
rm_screen_chose = popen("rm -rf ./screenDEV_chose.txt", "w");
pclose(rm_screen_chose);
return 0;
}