From 5939c27b60deea10e88482489ab1ea90ef2a06f2 Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 25 Mar 2016 21:51:21 +1100 Subject: [PATCH] Rewrite memory function to work on older linux kernel versions --- neofetch | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/neofetch b/neofetch index 8bac24d2..8711c556 100755 --- a/neofetch +++ b/neofetch @@ -1112,17 +1112,9 @@ getgpu () { getmemory () { case "$os" in "Linux") - # Read first 3 lines - mem=$(awk -F ':' '/MemTotal|MemAvailable/ {printf $2}' /proc/meminfo ) - - # Do some substitution on each line - memtotal=${mem/kB*/kB} - memavail=${mem/${memtotal}} - memtotal=${memtotal/kB*} - memavail=${memavail/kB*} - - memused=$((memtotal - memavail)) - memory="$((memused / 1024))MB / $((memtotal / 1024))MB" + mem=($(awk -F ':| kB' '/MemTotal|MemFree|Buffers|Cached/ {printf $2}' /proc/meminfo )) + memused=$((${mem[0]} - ${mem[1]} - ${mem[2]} - ${mem[3]})) + memory="$((memused / 1024))MB / $((${mem[0]} / 1024))MB" ;; "Mac OS X")