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 @@ -272,6 +272,7 @@ t_fans *retrieve_fans()
272
272
fan = (t_fans * ) malloc ( sizeof ( t_fans ) );
273
273
fan -> fan_output_path = strdup (path_output );
274
274
fan -> fan_manual_path = strdup (path_manual );
275
+ fan -> old_speed = 0 ;
275
276
276
277
if (fans_head == NULL ) {
277
278
fans_head = fan ;
@@ -373,13 +374,14 @@ void set_fan_speed(t_fans* fans, int speed)
373
374
t_fans * tmp = fans ;
374
375
375
376
while (tmp != NULL ) {
376
- if (tmp -> file != NULL ) {
377
+ if (tmp -> file != NULL && tmp -> old_speed != speed ) {
377
378
char buf [16 ];
378
379
int len = snprintf (buf , sizeof (buf ), "%d" , speed );
379
380
int res = pwrite (fileno (tmp -> file ), buf , len , /*offset=*/ 0 );
380
381
if (res == -1 ) {
381
382
perror ("Could not set fan speed" );
382
383
}
384
+ tmp -> old_speed = speed ;
383
385
}
384
386
385
387
tmp = tmp -> next ;
You can’t perform that action at this time.
0 commit comments