Use cpufreq if available instead of hardcoding it to specific distros
This commit is contained in:
parent
0e83e2099d
commit
3c3e2cc571
1 changed files with 16 additions and 19 deletions
35
fetch
35
fetch
|
@ -590,27 +590,24 @@ getcpu () {
|
||||||
cpu=${cpu/@*/}
|
cpu=${cpu/@*/}
|
||||||
|
|
||||||
# Get cpu speed
|
# Get cpu speed
|
||||||
case "$distro" in
|
if [ -d "/sys/devices/system/cpu/cpu0/cpufreq" ]; then
|
||||||
*"buntu"* | "CentOS"*)
|
case "$speed_type" in
|
||||||
speed=$(awk -F ': ' '/cpu MHz/ {printf $2; exit}' /proc/cpuinfo)
|
current) speed_type="scaling_cur_freq" ;;
|
||||||
speed=${speed/\./}
|
min) speed_type="scaling_min_freq" ;;
|
||||||
;;
|
max) speed_type="scaling_max_freq" ;;
|
||||||
|
bios) speed_type="bios_limit" ;;
|
||||||
|
scaling_current) speed_type="scaling_cur_freq" ;;
|
||||||
|
scaling_min) speed_type="scaling_min_freq" ;;
|
||||||
|
scaling_max) speed_type="scaling_max_freq" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
*)
|
read -r speed < \
|
||||||
case "$speed_type" in
|
/sys/devices/system/cpu/cpu0/cpufreq/${speed_type}
|
||||||
current) speed_type="scaling_cur_freq" ;;
|
|
||||||
min) speed_type="scaling_min_freq" ;;
|
|
||||||
max) speed_type="scaling_max_freq" ;;
|
|
||||||
bios) speed_type="bios_limit" ;;
|
|
||||||
scaling_current) speed_type="scaling_cur_freq" ;;
|
|
||||||
scaling_min) speed_type="scaling_min_freq" ;;
|
|
||||||
scaling_max) speed_type="scaling_max_freq" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
read -r speed < \
|
else
|
||||||
/sys/devices/system/cpu/cpu0/cpufreq/${speed_type}
|
speed=$(awk -F ': ' '/cpu MHz/ {printf $2; exit}' /proc/cpuinfo)
|
||||||
;;
|
speed=${speed/\./}
|
||||||
esac
|
fi
|
||||||
|
|
||||||
# Convert mhz to ghz without bc
|
# Convert mhz to ghz without bc
|
||||||
speed=$((speed / 100000))
|
speed=$((speed / 100000))
|
||||||
|
|
Loading…
Reference in a new issue