Merge pull request #674 from dylanaraps/speed_fix
CPU: Add option to show decimals in CPU speed.
This commit is contained in:
commit
fc06ad86cf
3 changed files with 24 additions and 9 deletions
15
neofetch
15
neofetch
|
@ -821,11 +821,10 @@ get_cpu() {
|
|||
speed="$(< "${speed_dir}/bios_limit")" || \
|
||||
speed="$(< "${speed_dir}/scaling_max_freq")" || \
|
||||
speed="$(< "${speed_dir}/cpuinfo_max_freq")"
|
||||
speed="$((speed / 100000))"
|
||||
speed="$((speed / 1000))"
|
||||
|
||||
else
|
||||
speed="$(awk -F ': |\\.' '/cpu MHz/ {printf $2; exit}' /proc/cpuinfo)"
|
||||
speed="$((speed / 100))"
|
||||
fi
|
||||
|
||||
# Get CPU temp.
|
||||
|
@ -893,7 +892,6 @@ get_cpu() {
|
|||
# Get CPU speed.
|
||||
speed="$(sysctl -n hw.cpuspeed)"
|
||||
[[ -z "$speed" ]] && speed="$(sysctl -n hw.clockrate)"
|
||||
speed="$((speed / 100))"
|
||||
|
||||
# Get CPU cores.
|
||||
cores="$(sysctl -n hw.ncpu)"
|
||||
|
@ -931,7 +929,6 @@ get_cpu() {
|
|||
|
||||
# Get CPU speed.
|
||||
speed="$(psrinfo -v | awk '/operates at/ {print $6; exit}')"
|
||||
speed="$((speed / 100))"
|
||||
|
||||
# Get CPU cores.
|
||||
case "$cpu_cores" in
|
||||
|
@ -948,7 +945,6 @@ get_cpu() {
|
|||
# Get CPU speed.
|
||||
speed="$(sysinfo -cpu | awk '/running at/ {print $NF; exit}')"
|
||||
speed="${speed/MHz}"
|
||||
speed="$((speed / 100))"
|
||||
|
||||
# Get CPU cores.
|
||||
cores="$(sysinfo -cpu | grep -c -F 'CPU #')"
|
||||
|
@ -961,7 +957,6 @@ get_cpu() {
|
|||
# Get CPU speed.
|
||||
speed="$(prtconf | awk -F':' '/Processor Clock Speed/ {printf $2}')"
|
||||
speed="${speed/MHz}"
|
||||
speed="$((speed / 100))"
|
||||
|
||||
# Get CPU cores.
|
||||
case "$cpu_cores" in
|
||||
|
@ -971,8 +966,12 @@ get_cpu() {
|
|||
;;
|
||||
esac
|
||||
|
||||
# Fix for speeds under 1ghz.
|
||||
if [[ "$speed" ]]; then
|
||||
# Hide decimals if on.
|
||||
[[ "$speed_shorthand" == "on" ]] && \
|
||||
speed="$((speed / 100))"
|
||||
|
||||
# Fix for speeds under 1ghz.
|
||||
if [[ -z "${speed:1}" ]]; then
|
||||
speed="0.${speed}"
|
||||
else
|
||||
|
@ -3794,6 +3793,7 @@ INFO:
|
|||
|
||||
NOTE: This only supports Linux with cpufreq.
|
||||
|
||||
--speed_shorthand on/off Whether or not to show decimals in CPU speed.
|
||||
--cpu_shorthand type Shorten the output of CPU
|
||||
Possible values: name, speed, tiny, on, off
|
||||
--cpu_cores type Whether or not to display the number of CPU cores
|
||||
|
@ -3999,6 +3999,7 @@ get_args() {
|
|||
"--cpu_cores") cpu_cores="$2" ;;
|
||||
"--cpu_speed") cpu_speed="$2" ;;
|
||||
"--speed_type") speed_type="$2" ;;
|
||||
"--speed_shorthand") speed_shorthand="$2" ;;
|
||||
"--distro_shorthand") distro_shorthand="$2" ;;
|
||||
"--kernel_shorthand") kernel_shorthand="$2" ;;
|
||||
"--uptime_shorthand") uptime_shorthand="$2" ;;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue