Fix cpuspeed on *buntu based systems

This commit is contained in:
Dylan 2016-01-19 22:30:17 +11:00
parent 4096d3c988
commit 515e2fb886
1 changed files with 14 additions and 4 deletions

18
fetch
View File

@ -73,7 +73,7 @@ use_wmctrl=0
# CPU
# CPU speed type
# Only works on Linux
# Only works on Linux with cpufreq.
# --speed_type current/min/max
speed_type="max"
@ -553,13 +553,23 @@ getcpu () {
cpu=${cpu/ @*/}
# Get cpu speed
speed_type=${speed_type/rent/}
read -r speed < \
/sys/devices/system/cpu/cpu0/cpufreq/scaling_${speed_type}_freq
case "$distro" in
*"buntu")
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
speed=$((speed / 100000))
speed=${speed:0:1}.${speed:1}
cpu="$cpu @ ${speed}GHz"
;;