Update neofetch
Separating calculations as shown in https://github.com/dylanaraps/neofetch/pull/2225#issuecomment-1296882170
This commit is contained in:
parent
ca13eb22e7
commit
d57463b0d3
1 changed files with 11 additions and 9 deletions
20
neofetch
20
neofetch
|
@ -2811,17 +2811,20 @@ get_memory() {
|
||||||
tib)
|
tib)
|
||||||
mem_label=TiB
|
mem_label=TiB
|
||||||
memory_unit_divider=$((1024 * 1024))
|
memory_unit_divider=$((1024 * 1024))
|
||||||
printf -v mem_used "%'.*f" \
|
|
||||||
"${mem_precision}" \
|
|
||||||
$((mem_used / memory_unit_divider)).$((mem_used % memory_unit_divider))
|
|
||||||
printf -v mem_total "%'.*f" \
|
|
||||||
"${mem_precision}" \
|
|
||||||
$((mem_total / memory_unit_divider)).$((mem_total % memory_unit_divider))
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
gib)
|
gib)
|
||||||
mem_label=GiB
|
mem_label=GiB
|
||||||
memory_unit_divider=1024
|
memory_unit_divider=1024
|
||||||
|
;;
|
||||||
|
|
||||||
|
kib)
|
||||||
|
mem_label=KiB
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case $mem_label in
|
||||||
|
GiB|TiB)
|
||||||
printf -v mem_used "%'.*f" \
|
printf -v mem_used "%'.*f" \
|
||||||
"${mem_precision}" \
|
"${mem_precision}" \
|
||||||
$((mem_used / memory_unit_divider)).$((mem_used % memory_unit_divider))
|
$((mem_used / memory_unit_divider)).$((mem_used % memory_unit_divider))
|
||||||
|
@ -2830,11 +2833,10 @@ get_memory() {
|
||||||
$((mem_total / memory_unit_divider)).$((mem_total % memory_unit_divider))
|
$((mem_total / memory_unit_divider)).$((mem_total % memory_unit_divider))
|
||||||
;;
|
;;
|
||||||
|
|
||||||
kib)
|
KiB)
|
||||||
mem_used=$((mem_used * 1024))
|
mem_used=$((mem_used * 1024))
|
||||||
mem_total=$((mem_total * 1024))
|
mem_total=$((mem_total * 1024))
|
||||||
mem_label=KiB
|
;;
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
memory="${mem_used}${mem_label:-MiB} / ${mem_total}${mem_label:-MiB} ${mem_perc:+(${mem_perc}%)}"
|
memory="${mem_used}${mem_label:-MiB} / ${mem_total}${mem_label:-MiB} ${mem_perc:+(${mem_perc}%)}"
|
||||||
|
|
Loading…
Reference in a new issue