Fix usage on BSD
This commit is contained in:
parent
d3c2216f48
commit
1be5423b1d
27
neofetch
27
neofetch
|
@ -1161,28 +1161,23 @@ getcpu () {
|
||||||
|
|
||||||
getcpu_usage () {
|
getcpu_usage () {
|
||||||
case "$os" in
|
case "$os" in
|
||||||
"Linux" | "Mac OS X" | "iPhone OS")
|
|
||||||
# Get cores if unset
|
|
||||||
if [ -z "$cores" ]; then
|
|
||||||
case "$os" in
|
|
||||||
"Linux") cores="$(awk -F ': ' '/siblings/ {printf $2; exit}' /proc/cpuinfo)" ;;
|
|
||||||
"Mac OS X") cores="$(sysctl -n hw.ncpu)" ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
cpu_usage="$(ps aux | awk 'BEGIN { sum = 0 } { sum += $3 }; END { print sum }')"
|
|
||||||
cpu_usage="$((${cpu_usage/\.*} / ${cores:-1}))"
|
|
||||||
;;
|
|
||||||
|
|
||||||
"Windows")
|
"Windows")
|
||||||
cpu_usage="$(wmic cpu get loadpercentage /value)"
|
cpu_usage="$(wmic cpu get loadpercentage /value)"
|
||||||
cpu_usage="${cpu_usage/LoadPercentage'='}"
|
cpu_usage="${cpu_usage/LoadPercentage'='}"
|
||||||
cpu_usage="${cpu_usage//[[:space:]]}"
|
cpu_usage="${cpu_usage//[[:space:]]}"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"BSD")
|
"Linux" | "Mac OS X" | "iPhone OS" | "BSD")
|
||||||
# BSD support coming soon.
|
# Get cores if unset
|
||||||
return
|
if [ -z "$cores" ]; then
|
||||||
|
case "$os" in
|
||||||
|
"Linux") cores="$(awk -F ': ' '/siblings/ {printf $2; exit}' /proc/cpuinfo)" ;;
|
||||||
|
"Mac OS X" | "BSD") cores="$(sysctl -n hw.ncpu)" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
cpu_usage="$(ps aux | awk 'BEGIN { sum = 0 } { sum += $3 }; END { print sum }')"
|
||||||
|
cpu_usage="$((${cpu_usage/\.*} / ${cores:-1}))"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
Reference in New Issue