From d8561cceed7b4cd47da2e94db6d9ea39a74ef1cb Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 9 Mar 2017 11:47:52 +1100 Subject: [PATCH 1/2] CPU: Show an additional digit in cpu speed --- neofetch | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/neofetch b/neofetch index b63788aa..16126600 100755 --- a/neofetch +++ b/neofetch @@ -810,11 +810,11 @@ get_cpu() { speed="$(< "${speed_dir}/bios_limit")" || \ speed="$(< "${speed_dir}/scaling_max_freq")" || \ speed="$(< "${speed_dir}/cpuinfo_max_freq")" - speed="$((speed / 100000))" + speed="$((speed / 10000))" else speed="$(awk -F ': |\\.' '/cpu MHz/ {printf $2; exit}' /proc/cpuinfo)" - speed="$((speed / 100))" + speed="$((speed / 10))" fi # Get CPU temp. @@ -882,7 +882,7 @@ get_cpu() { # Get CPU speed. speed="$(sysctl -n hw.cpuspeed)" [[ -z "$speed" ]] && speed="$(sysctl -n hw.clockrate)" - speed="$((speed / 100))" + speed="$((speed / 10))" # Get CPU cores. cores="$(sysctl -n hw.ncpu)" @@ -920,7 +920,7 @@ get_cpu() { # Get CPU speed. speed="$(psrinfo -v | awk '/operates at/ {print $6; exit}')" - speed="$((speed / 100))" + speed="$((speed / 10))" # Get CPU cores. case "$cpu_cores" in @@ -937,7 +937,7 @@ get_cpu() { # Get CPU speed. speed="$(sysinfo -cpu | awk '/running at/ {print $NF; exit}')" speed="${speed/MHz}" - speed="$((speed / 100))" + speed="$((speed / 10))" # Get CPU cores. cores="$(sysinfo -cpu | grep -c -F 'CPU #')" @@ -950,7 +950,7 @@ get_cpu() { # Get CPU speed. speed="$(prtconf | awk -F':' '/Processor Clock Speed/ {printf $2}')" speed="${speed/MHz}" - speed="$((speed / 100))" + speed="$((speed / 10))" # Get CPU cores. case "$cpu_cores" in From 30a6d8641b42192d11317a43cb7f6d959c160c6a Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 9 Mar 2017 12:03:17 +1100 Subject: [PATCH 2/2] CPU: Added speed_shorthand to toggle showing decimals in the output --- config/config | 11 +++++++++++ neofetch | 15 ++++++++------- neofetch.1 | 7 +++++-- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/config/config b/config/config index 2a57fe3f..d1621962 100644 --- a/config/config +++ b/config/config @@ -138,6 +138,17 @@ shell_version="on" # NOTE: Any file in '/sys/devices/system/cpu/cpu0/cpufreq' can be used as a value. speed_type="bios_limit" +# CPU speed shorthand +# +# Default: 'off' +# Values: 'on', 'off'. +# Flag: --speed_shorthand. +# +# Example: +# on: 'i7-6500U (4) @ 3.1GHz' +# off: 'i7-6500U (4) @ 3.100GHz' +speed_shorthand="off" + # Shorten the output of the CPU function # # Default: 'off' diff --git a/neofetch b/neofetch index 16126600..6a045651 100755 --- a/neofetch +++ b/neofetch @@ -810,11 +810,10 @@ get_cpu() { speed="$(< "${speed_dir}/bios_limit")" || \ speed="$(< "${speed_dir}/scaling_max_freq")" || \ speed="$(< "${speed_dir}/cpuinfo_max_freq")" - speed="$((speed / 10000))" + speed="$((speed / 1000))" else speed="$(awk -F ': |\\.' '/cpu MHz/ {printf $2; exit}' /proc/cpuinfo)" - speed="$((speed / 10))" fi # Get CPU temp. @@ -882,7 +881,6 @@ get_cpu() { # Get CPU speed. speed="$(sysctl -n hw.cpuspeed)" [[ -z "$speed" ]] && speed="$(sysctl -n hw.clockrate)" - speed="$((speed / 10))" # Get CPU cores. cores="$(sysctl -n hw.ncpu)" @@ -920,7 +918,6 @@ get_cpu() { # Get CPU speed. speed="$(psrinfo -v | awk '/operates at/ {print $6; exit}')" - speed="$((speed / 10))" # Get CPU cores. case "$cpu_cores" in @@ -937,7 +934,6 @@ get_cpu() { # Get CPU speed. speed="$(sysinfo -cpu | awk '/running at/ {print $NF; exit}')" speed="${speed/MHz}" - speed="$((speed / 10))" # Get CPU cores. cores="$(sysinfo -cpu | grep -c -F 'CPU #')" @@ -950,7 +946,6 @@ get_cpu() { # Get CPU speed. speed="$(prtconf | awk -F':' '/Processor Clock Speed/ {printf $2}')" speed="${speed/MHz}" - speed="$((speed / 10))" # Get CPU cores. case "$cpu_cores" in @@ -960,8 +955,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 @@ -3739,6 +3738,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 @@ -3944,6 +3944,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" ;; diff --git a/neofetch.1 b/neofetch.1 index a51742df..245cbbb7 100644 --- a/neofetch.1 +++ b/neofetch.1 @@ -1,5 +1,5 @@ -.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.3. -.TH NEOFETCH "1" "February 2017" "Neofetch 3.0.2" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.1. +.TH NEOFETCH "1" "March 2017" "Neofetch 3.0.2" "User Commands" .SH NAME Neofetch \- A fast, highly customizable system info script .SH SYNOPSIS @@ -30,6 +30,9 @@ scaling_current, scaling_min, scaling_max .IP NOTE: This only supports Linux with cpufreq. .TP +\fB\-\-speed_shorthand\fR on/off +Whether or not to show decimals in CPU speed. +.TP \fB\-\-cpu_shorthand\fR type Shorten the output of CPU Possible values: name, speed, tiny, on, off