diff --git a/fetch b/fetch index a1723bb5..22aaf5fd 100755 --- a/fetch +++ b/fetch @@ -590,27 +590,24 @@ 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" ;; + 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 - *) - case "$speed_type" in - 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 < \ + /sys/devices/system/cpu/cpu0/cpufreq/${speed_type} - 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))