Linux memory, fix read causing hang on older systems
This commit is contained in:
parent
be7a505c30
commit
45b2d7f748
1 changed files with 3 additions and 7 deletions
10
neofetch
10
neofetch
|
@ -1112,16 +1112,12 @@ getmemory () {
|
||||||
case "$os" in
|
case "$os" in
|
||||||
"Linux")
|
"Linux")
|
||||||
# Read first 3 lines
|
# Read first 3 lines
|
||||||
exec 6< /proc/meminfo
|
mem=$(awk -F ':' '/MemTotal|MemAvailable/ {printf $2}' /proc/meminfo )
|
||||||
read -r memtotal <&6
|
|
||||||
read -r memfree <&6 # We don't actually use this var
|
|
||||||
read -r memavail <&6
|
|
||||||
exec 6<&-
|
|
||||||
|
|
||||||
# Do some substitution on each line
|
# Do some substitution on each line
|
||||||
memtotal=${memtotal/MemTotal:}
|
memtotal=${mem/kB*/kB}
|
||||||
|
memavail=${mem/${memtotal}}
|
||||||
memtotal=${memtotal/kB*}
|
memtotal=${memtotal/kB*}
|
||||||
memavail=${memavail/MemAvailable:}
|
|
||||||
memavail=${memavail/kB*}
|
memavail=${memavail/kB*}
|
||||||
|
|
||||||
memused=$((memtotal - memavail))
|
memused=$((memtotal - memavail))
|
||||||
|
|
Loading…
Reference in a new issue