From 45b2d7f7480404e2679d7c68f3ac9c855255c7d8 Mon Sep 17 00:00:00 2001 From: Dylan Date: Thu, 17 Mar 2016 14:57:25 +1100 Subject: [PATCH] Linux memory, fix read causing hang on older systems --- neofetch | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/neofetch b/neofetch index 0a7ff35e..1dd1d335 100755 --- a/neofetch +++ b/neofetch @@ -1112,16 +1112,12 @@ getmemory () { case "$os" in "Linux") # Read first 3 lines - exec 6< /proc/meminfo - read -r memtotal <&6 - read -r memfree <&6 # We don't actually use this var - read -r memavail <&6 - exec 6<&- + mem=$(awk -F ':' '/MemTotal|MemAvailable/ {printf $2}' /proc/meminfo ) # Do some substitution on each line - memtotal=${memtotal/MemTotal:} + memtotal=${mem/kB*/kB} + memavail=${mem/${memtotal}} memtotal=${memtotal/kB*} - memavail=${memavail/MemAvailable:} memavail=${memavail/kB*} memused=$((memtotal - memavail))