Use cpufreq if available instead of hardcoding it to specific distros

This commit is contained in:
Dylan 2016-01-26 12:55:31 +11:00
parent 0e83e2099d
commit 3c3e2cc571
1 changed files with 16 additions and 19 deletions

15
fetch
View File

@ -590,13 +590,7 @@ getcpu () {
cpu=${cpu/@*/}
# Get cpu speed
case "$distro" in
*"buntu"* | "CentOS"*)
speed=$(awk -F ': ' '/cpu MHz/ {printf $2; exit}' /proc/cpuinfo)
speed=${speed/\./}
;;
*)
if [ -d "/sys/devices/system/cpu/cpu0/cpufreq" ]; then
case "$speed_type" in
current) speed_type="scaling_cur_freq" ;;
min) speed_type="scaling_min_freq" ;;
@ -609,8 +603,11 @@ getcpu () {
read -r speed < \
/sys/devices/system/cpu/cpu0/cpufreq/${speed_type}
;;
esac
else
speed=$(awk -F ': ' '/cpu MHz/ {printf $2; exit}' /proc/cpuinfo)
speed=${speed/\./}
fi
# Convert mhz to ghz without bc
speed=$((speed / 100000))