File tree Expand file tree Collapse file tree 2 files changed +4
-1
lines changed Expand file tree Collapse file tree 2 files changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ struct s_fans {
19
19
char * path ; // TODO: unused
20
20
char * fan_output_path ;
21
21
char * fan_manual_path ;
22
+ int old_speed ;
22
23
struct s_fans * next ;
23
24
};
24
25
Original file line number Diff line number Diff line change @@ -273,6 +273,7 @@ t_fans *retrieve_fans()
273
273
fan = (t_fans * ) malloc ( sizeof ( t_fans ) );
274
274
fan -> fan_output_path = strdup (path_output );
275
275
fan -> fan_manual_path = strdup (path_manual );
276
+ fan -> old_speed = 0 ;
276
277
277
278
if (fans_head == NULL ) {
278
279
fans_head = fan ;
@@ -374,10 +375,11 @@ void set_fan_speed(t_fans* fans, int speed)
374
375
t_fans * tmp = fans ;
375
376
376
377
while (tmp != NULL ) {
377
- if (tmp -> file != NULL ) {
378
+ if (tmp -> file != NULL && tmp -> old_speed != speed ) {
378
379
char buf [16 ];
379
380
int len = snprintf (buf , sizeof (buf ), "%d" , speed );
380
381
pwrite (fileno (tmp -> file ), buf , len , /*offset=*/ 0 );
382
+ tmp -> old_speed = speed ;
381
383
}
382
384
383
385
tmp = tmp -> next ;
You can’t perform that action at this time.
0 commit comments