mirror of
https://github.com/dylanaraps/neofetch.git
synced 2025-10-04 09:08:38 +00:00
Use cpufreq if available instead of hardcoding it to specific distros
This commit is contained in:
15
fetch
15
fetch
@@ -590,13 +590,7 @@ 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"*)
|
|
||||||
speed=$(awk -F ': ' '/cpu MHz/ {printf $2; exit}' /proc/cpuinfo)
|
|
||||||
speed=${speed/\./}
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
case "$speed_type" in
|
case "$speed_type" in
|
||||||
current) speed_type="scaling_cur_freq" ;;
|
current) speed_type="scaling_cur_freq" ;;
|
||||||
min) speed_type="scaling_min_freq" ;;
|
min) speed_type="scaling_min_freq" ;;
|
||||||
@@ -609,8 +603,11 @@ getcpu () {
|
|||||||
|
|
||||||
read -r speed < \
|
read -r speed < \
|
||||||
/sys/devices/system/cpu/cpu0/cpufreq/${speed_type}
|
/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
|
# Convert mhz to ghz without bc
|
||||||
speed=$((speed / 100000))
|
speed=$((speed / 100000))
|
||||||
|
Reference in New Issue
Block a user