memory: haiku support

This commit is contained in:
Dylan Araps 2019-09-26 10:11:57 +03:00
parent 746fb0b735
commit 295fc22a41

16
pfetch
View File

@ -494,6 +494,22 @@ get_memory() {
mem_used=$((mem_full - mem_free))
;;
Haiku)
# Read the first line of 'sysinfo -mem' splitting on
# '(', ' ', and ')'. The needed information is then
# sotred in the 5th and 7th elements. Using '_' "consumes"
# an element allowing us to proceed to the next one.
#
# The parsed format is as follows:
# 3501142016 bytes free (used/max 792645632 / 4293787648)
IFS='( )' read -r _ _ _ _ mem_used _ mem_full <<-EOF
$(sysinfo -mem)
EOF
mem_used=$((mem_used / 1024 / 1024))
mem_full=$((mem_full / 1024 / 1024))
;;
esac
log memory "${mem_used:-?}M / ${mem_full:-?}M" >&6