Fix cpuspeed on *buntu based systems

This commit is contained in:
Dylan 2016-01-19 22:30:17 +11:00
parent 4096d3c988
commit 515e2fb886

18
fetch
View file

@ -73,7 +73,7 @@ use_wmctrl=0
# CPU # CPU
# CPU speed type # CPU speed type
# Only works on Linux # Only works on Linux with cpufreq.
# --speed_type current/min/max # --speed_type current/min/max
speed_type="max" speed_type="max"
@ -553,13 +553,23 @@ getcpu () {
cpu=${cpu/ @*/} cpu=${cpu/ @*/}
# Get cpu speed # Get cpu speed
speed_type=${speed_type/rent/} case "$distro" in
read -r speed < \ *"buntu")
/sys/devices/system/cpu/cpu0/cpufreq/scaling_${speed_type}_freq speed=$(awk -F ': ' '/cpu Mhz/ {printf $2}' /proc/cpuinfo)
speed=${speed/\./}
;;
*)
speed_type=${speed_type/rent/}
read -r speed < \
/sys/devices/system/cpu/cpu0/cpufreq/scaling_${speed_type}_freq
;;
esac
# Convert mhz to ghz without bc # Convert mhz to ghz without bc
speed=$((speed / 100000)) speed=$((speed / 100000))
speed=${speed:0:1}.${speed:1} speed=${speed:0:1}.${speed:1}
cpu="$cpu @ ${speed}GHz" cpu="$cpu @ ${speed}GHz"
;; ;;