Cleanup CPU function

This commit is contained in:
Dylan 2016-03-26 23:17:27 +11:00
parent 95c744f0f8
commit b4f19e8a3d

View file

@ -819,11 +819,7 @@ getcpu () {
case "$os" in case "$os" in
"Linux") "Linux")
# Get cpu name # Get cpu name
cpu="$(grep -F 'model name' /proc/cpuinfo)" cpu="$(awk -F ': | @' '/model name/ {printf $2; exit}' /proc/cpuinfo)"
cpu=${cpu/model name*: }
cpu=${cpu/ @*}
cpu=${cpu// }
cpu=${cpu%% }
# Get cpu speed # Get cpu speed
if [ -d "/sys/devices/system/cpu/cpu0/cpufreq" ]; then if [ -d "/sys/devices/system/cpu/cpu0/cpufreq" ]; then
@ -841,8 +837,7 @@ getcpu () {
/sys/devices/system/cpu/cpu0/cpufreq/${speed_type} /sys/devices/system/cpu/cpu0/cpufreq/${speed_type}
else else
speed=$(awk -F ': ' '/cpu MHz/ {printf $2; exit}' /proc/cpuinfo) speed=$(awk -F ': |\\.' '/cpu MHz/ {printf $2; exit}' /proc/cpuinfo)
speed=${speed/\.}
fi fi
# Convert mhz to ghz without bc # Convert mhz to ghz without bc