-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
51 lines (44 loc) · 1.03 KB
/
Copy pathmain.c
File metadata and controls
51 lines (44 loc) · 1.03 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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
int main(int argc,char *argv[]){
int id;
FILE *pipe;
pipe = popen("xinput | grep M575","r");
int len=0;
char path[5000];
fgets(path, 5000, pipe);
FILE *sensFile = fopen("/tmp/sens.txt","r+");
float sensivity;
if(sensFile == NULL){
sensFile = fopen("/tmp/sens.txt","w+");
sensivity=0.5;
return 1;
}else {
fscanf(sensFile,"%f",&sensivity);
}
if(strlen(path)<80)
{
pipe = popen("xinput | grep M575 | awk '{print $6}' | cut -c4-6","r");
fgets(path, 5000, pipe);
id = atoi(path);
}
if (!(strcmp("up", argv[1])) && sensivity < 1.0) {
sensivity += 0.05;
}
if (!(strcmp("down", argv[1])) && sensivity > -1.0) {
sensivity -= 0.05;
}
if (sensivity > 1.0) {
sensivity = 1.0;
} else if (sensivity < -1.0) {
sensivity = -1.0;
}
rewind(sensFile);
fprintf(sensFile,"%.2f",sensivity);
char command[50];
sprintf(command,"xinput --set-prop %d 'libinput Accel Speed' %f",id,sensivity);
system(command);
return 0;
}