From 0da7269a965f8894d4607b8574f7b36e963d467e Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 28 Dec 2016 12:33:34 +1100 Subject: [PATCH 1/5] CPU: Add option to display output in fahrenheit --- config/config | 5 +++-- neofetch | 25 ++++++++++++++++++++----- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/config/config b/config/config index 2e33b74f..36ebe853 100644 --- a/config/config +++ b/config/config @@ -186,12 +186,13 @@ cpu_cores="logical" # Note the temperature is added to the regular CPU function. # # Default: 'off' -# Values: 'on', 'off' +# Values: 'C', 'F', 'off' # Flag: --cpu_temp # Supports: Linux # # Example: -# on: 'Intel i7-6500U (4) @ 3.1GHz [27.2°C]' +# C: 'Intel i7-6500U (4) @ 3.1GHz [27.2°C]' +# F: 'Intel i7-6500U (4) @ 3.1GHz [82.0°C]' # off: 'Intel i7-6500U (4) @ 3.1GHz' cpu_temp="off" diff --git a/neofetch b/neofetch index f56771d9..5aadb5f1 100755 --- a/neofetch +++ b/neofetch @@ -786,10 +786,15 @@ get_cpu() { fi # Get CPU temp. - if [[ "$cpu_temp" == "on" && -f "$temp_dir" ]]; then + if [[ "$cpu_temp" != "off" && -f "$temp_dir" ]]; then temp="$(< "$temp_dir")" temp="$((temp * 100 / 10000))" - temp="[${temp/${temp: -1}}.${temp: -1}°C]" + + # Convert to fahrenheit if enabled. + [[ "$cpu_temp" == "F" ]] && temp="$((temp * 90 / 50 + 320))" + + # Format the output. + temp="[${temp/${temp: -1}}.${temp: -1}°${cpu_temp:-C}]" fi # Get CPU cores. @@ -851,17 +856,27 @@ get_cpu() { cores="$(sysctl -n hw.ncpu)" # Get CPU temp. - if [[ "$cpu_temp" == "on" ]]; then + if [[ "$cpu_temp" != "off" ]]; then case "$kernel_name" in "FreeBSD"* | "DragonFly"*) temp="$(sysctl -n dev.cpu.0.temperature)" - temp="[${temp/C/°C}]" + temp="${temp/C}" ;; "OpenBSD"* | "Bitrig"*) temp="$(sysctl -n hw.sensors.lm0.temp0)" - temp="[${temp/ degC/°C}]" + temp="${temp/ degC}" ;; esac + + # Convert to fahrenheit if enabled. + if [[ "$cpu_temp" == "F" ]]; then + temp="${temp//.}" + temp="$((temp * 90 / 50 + 320))" + temp="[${temp/${temp: -1}}.${temp: -1}°F]" + else + temp="[${temp}°C]" + fi + fi ;; From 9f080ee2f77cca9174634fb4d0b8523f71fac9a2 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 28 Dec 2016 12:33:19 +1100 Subject: [PATCH 2/5] Update config --- config/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config b/config/config index 36ebe853..4a13c6bd 100644 --- a/config/config +++ b/config/config @@ -192,7 +192,7 @@ cpu_cores="logical" # # Example: # C: 'Intel i7-6500U (4) @ 3.1GHz [27.2°C]' -# F: 'Intel i7-6500U (4) @ 3.1GHz [82.0°C]' +# F: 'Intel i7-6500U (4) @ 3.1GHz [82.0°F]' # off: 'Intel i7-6500U (4) @ 3.1GHz' cpu_temp="off" From db22297738ce25dab6c8aa4aadf63818bbb8b77d Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 2 Jan 2017 11:27:37 +1100 Subject: [PATCH 3/5] CPU Temp: Fix issue with old values --- neofetch | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/neofetch b/neofetch index 13d3f31f..9810b290 100755 --- a/neofetch +++ b/neofetch @@ -2825,11 +2825,13 @@ get_user_config() { if [[ -f "$config_file" ]]; then source "$config_file" err "Config: Sourced user config. (${config_file})" + old_options return elif [[ "$config_file" == "travis" ]]; then source "$travis_config" err "Config: Sourced user config. (${travis_config})" + old_options return fi mkdir -p "${XDG_CONFIG_HOME}/neofetch/" @@ -2856,8 +2858,6 @@ get_user_config() { source "$config_file" err "Config: Sourced user config. (${config_file})" - - # Check for deprecated options. old_options } @@ -3009,6 +3009,9 @@ old_options() { # $start and $end were replaced with ${block_range[@]} in 2.1.0. [[ "$start" && "$end" ]] && { err "Config: \$start and \$end are deprecated, use block_range=(0 7) instead."; block_range=("$start" "$end"); } + + # Fahrenheit support was added to CPU so the options were changed. + [[ "$cpu_temp" == "on" ]] && { err "Config: cpu_temp='on' is deprecated, use cpu_temp='C' or 'F' instead."; cpu_temp="C"; } } cache_uname() { @@ -3336,7 +3339,6 @@ get_args() { "--os_arch") os_arch="$2" ;; "--cpu_cores") cpu_cores="$2" ;; "--cpu_speed") cpu_speed="$2" ;; - "--cpu_temp") cpu_temp="$2" ;; "--speed_type") speed_type="$2" ;; "--distro_shorthand") distro_shorthand="$2" ;; "--kernel_shorthand") kernel_shorthand="$2" ;; @@ -3354,6 +3356,11 @@ get_args() { "--song_shorthand") song_shorthand="$2" ;; "--install_time") install_time="$2" ;; "--install_time_format") install_time_format="$2" ;; + "--cpu_temp") + cpu_temp="$2" + [[ "$cpu_temp" == "on" ]] && cpu_temp="C" + ;; + "--disable") for func in "$@"; do case "$func" in From e54fd50eb1cfb1072f47006fa1fd40319f268ab0 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 2 Jan 2017 11:30:34 +1100 Subject: [PATCH 4/5] Docs: Update docs --- neofetch | 2 +- neofetch.1 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/neofetch b/neofetch index 9810b290..2b982ffb 100755 --- a/neofetch +++ b/neofetch @@ -3170,7 +3170,7 @@ INFO: NOTE: 'physical' doesn't work on BSD. --cpu_speed on/off Hide/Show cpu speed. - --cpu_temp on/off Hide/Show cpu temperature. + --cpu_temp C/F/off Hide/Show cpu temperature. NOTE: This only works on Linux and BSD. diff --git a/neofetch.1 b/neofetch.1 index dd1e1cda..7beca468 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" "December 2016" "Neofetch 2.1.0" "User Commands" +.TH NEOFETCH "1" "January 2017" "Neofetch 2.1.0" "User Commands" .SH NAME Neofetch \- A fast, highly customizable system info script .SH SYNOPSIS @@ -43,7 +43,7 @@ NOTE: 'physical' doesn't work on BSD. \fB\-\-cpu_speed\fR on/off Hide/Show cpu speed. .TP -\fB\-\-cpu_temp\fR on/off +\fB\-\-cpu_temp\fR C/F/off Hide/Show cpu temperature. .IP NOTE: This only works on Linux and BSD. From 3f0a58b19294815b30f5e8eb90f7c724c6009b2f Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 2 Jan 2017 11:34:42 +1100 Subject: [PATCH 5/5] Config: Update travis --- config/travis | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/travis b/config/travis index 42431a17..ff4435fe 100644 --- a/config/travis +++ b/config/travis @@ -45,4 +45,4 @@ shell_version="on" cpu_display="infobar" memory_display="infobar" disk_display="infobar" -cpu_temp="on" +cpu_temp="C"