diff options
| -rw-r--r-- | cpu.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -5,13 +5,15 @@ #define BG0 "#acae3299" #define BG1 "#ea544399" FILE *proc_stat; -int cpu_delay = 6, cpu_stat[8]; +int cpu_delay_val = 15, + cpu_delay = 15, + cpu_stat[8]; char cpu_str[12]; int total, idle; double cpu_usage_p; void cpu(void) { - if (cpu_delay++ < 6) goto show_stat; + if (cpu_delay++ < cpu_delay_val) goto show_stat; else cpu_delay = 0; int prev_idle, prev_total; char buf[64]; @@ -33,8 +35,9 @@ void cpu(void) cpu_usage_p = total - prev_total; cpu_usage_p *= 100; cpu_usage_p /= ((float)idle + total) - (prev_idle + prev_total); + if (cpu_usage_p > 40) cpu_delay_val = 1; + else cpu_delay_val = 15; snprintf(cpu_str,12,ICON_CPU"%02.02f%%",cpu_usage_p); show_stat: - if (cpu_usage_p < 60) block(cpu_str,FG,BG0,BG0); - else block(cpu_str,FG,BG1,BG1); + if (cpu_delay_val == 1) block(cpu_str,FG,BG1,BG1); } |