diff options
| author | Inqiyad Sabr <sabr@ariamath.xyz> | 2025-11-19 11:54:44 +0600 |
|---|---|---|
| committer | Inqiyad Sabr <sabr@ariamath.xyz> | 2025-11-19 11:54:44 +0600 |
| commit | 918497c72140491cd949c136b053cf47a2e5c1b0 (patch) | |
| tree | 8a26786f54108839413fc399245a6b5392da1aa3 | |
| parent | bcf99629acee9083f390cd459169f3c1c3d11da7 (diff) | |
| -rw-r--r-- | mem.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -9,15 +9,16 @@ n = 10 * n + (c - '0') #define jmpl(n) fseek(meminfo,29*(n-1),0) FILE *meminfo; -int mem_delay = 3; +int high_mem_p, + mem_delay_val = 30, + mem_delay = 30; char mem_str[15]; void mem(void) { - if (mem_delay++ < 3) goto show_stat; + if (mem_delay++ < mem_delay_val) goto show_stat; else mem_delay = 0; if (!meminfo) meminfo = fopen("/proc/meminfo","r"); - int c, mem; - int total, free, buffers, + int c, mem, total, free, buffers, cached, shared, reclaim; jmpl(1); get_mem_val(total); jmpl(2); get_mem_val(free); @@ -26,8 +27,11 @@ void mem(void) jmpl(23); get_mem_val(shared); jmpl(26); get_mem_val(reclaim); mem = total + reclaim - (free+buffers+cached+shared); + high_mem_p = (60*total/100); + if (mem > high_mem_p) mem_delay_val = 2; + else mem_delay_val = 30; mem /= 1024; snprintf(mem_str,15,ICON_MEM"%5d MiB",mem); show_stat: - block(mem_str,FG,BG,BG); + if (mem_delay_val == 2) block(mem_str,FG,BG,BG); } |