From eb62c843c9c1cb5d34b56f6636c92e73923f8738 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 1 Aug 2017 01:56:46 +1000 Subject: [PATCH 1/8] gpu: Hide duplicate identical gpus --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 5e36617c..d627a4c4 100755 --- a/neofetch +++ b/neofetch @@ -1113,7 +1113,7 @@ get_gpu() { "Linux") # Read GPUs into array. IFS=$'\n' - gpus=($(lspci -mm | awk -F '\\"|\\" \\"' '/"Display|"3D|"VGA/ {print $3 " " $4}')) + gpus=($(lspci -mm | awk -F '\\"|\\" \\"|\\(' '/"Display|"3D|"VGA/ {print $3 " " $4}' | uniq)) IFS="$old_ifs" # Number the GPUs if more than one exists. From e7168245e1dc263483f7c8bffa6b88f7b7149d73 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 1 Aug 2017 21:25:07 +1000 Subject: [PATCH 2/8] gpu: Correctly filter out duplicates --- neofetch | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/neofetch b/neofetch index d627a4c4..ec3001b5 100755 --- a/neofetch +++ b/neofetch @@ -1113,7 +1113,9 @@ get_gpu() { "Linux") # Read GPUs into array. IFS=$'\n' - gpus=($(lspci -mm | awk -F '\\"|\\" \\"|\\(' '/"Display|"3D|"VGA/ {print $3 " " $4}' | uniq)) + gpus=($(lspci -mm | awk -F '\\"|\\" \\"|\\(' \ + '/"Display|"3D|"VGA/ {a[$0] = $3 " " $4} END{for(i in a) + {if(!seen[a[i]]++) print a[i]}}')) IFS="$old_ifs" # Number the GPUs if more than one exists. From e9f6ffc2d9bd31af25c7cbf13c1dcce57886ad97 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 2 Aug 2017 07:13:58 +1000 Subject: [PATCH 3/8] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbeb487a..eb8d4fa5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,10 @@ - Fixed inaccurate speed output in systems with CPU speed less than 1 GHz. - Deprecated `cpu_shorthand` in favor of `cpu_brand`. +**GPU** + +- [Linux] Filter out duplicate entries. + **Uptime** - [AIX/IRIX] Fixed Neofetch crashing when calculating uptime. From 04c22a8edd6064b63aac557597bae565f4848f8b Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Thu, 3 Aug 2017 15:16:52 +0700 Subject: [PATCH 4/8] Misc: Reimplement stdout --- neofetch | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/neofetch b/neofetch index ec3001b5..9e49c2d6 100755 --- a/neofetch +++ b/neofetch @@ -2801,7 +2801,7 @@ prin() { string="${subtitle_color}${bold}${string}" # Print the info. - printf "%b\n" "${text_padding:+\033[${text_padding}C}${zws}${string}${reset} " + printf "%b\n" "${text_padding:+\033[${text_padding}C}${zws}${string}${reset}" # Calculate info height. ((++info_height)) @@ -2813,7 +2813,7 @@ prin() { get_underline() { if [[ "$underline_enabled" == "on" ]]; then printf -v underline "%${length}s" - printf "%b\n" "${text_padding:+\033[${text_padding}C}${zws}${underline_color}${underline// /$underline_char}${reset} " + printf "%b\n" "${text_padding:+\033[${text_padding}C}${zws}${underline_color}${underline// /$underline_char}${reset}" unset -v length fi prin=1 @@ -3636,6 +3636,20 @@ color() { # OTHER +stdout() { + image_backend="off" + unset subtitle_color + unset colon_color + unset info_color + unset underline_color + unset bold + unset title_color + unset at_color + unset text_padding + unset zws + unset reset +} + err() { err+="$(color 1)[!]\033[0m $1\n" } @@ -4401,6 +4415,7 @@ get_args() { ;; esac ;; + "--stdout") stdout="on" ;; "-v") verbose="on" ;; "-vv") set -x; verbose="on" ;; "--help") usage ;; @@ -4421,9 +4436,10 @@ main() { get_distro get_bold get_distro_colors + [[ "$stdout" == "on" ]] && stdout # Minix doesn't support these sequences. - if [[ "$TERM" != "minix" ]]; then + if [[ "$TERM" != "minix" && "$stdout" != "on" ]]; then # If the script exits for any reason, unhide the cursor. trap 'printf "\033[?25h\033[?7h"' EXIT From faa71d0f95571800a8eaea221a8a6f915ff46ff8 Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Fri, 4 Aug 2017 00:15:55 +0700 Subject: [PATCH 5/8] Docs: CHANGELOG and manpage --- CHANGELOG.md | 1 + config/config.conf | 6 ++++++ neofetch | 1 + neofetch.1 | 5 ++++- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb8d4fa5..4f4abcae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Config file now has a `.conf` suffix. - Neofetch now assumes target directories (config file and ASCII directory) at install time, this fixes problems with systems such as NixOS. +- `stdout` mode is now reimplemented. ## Operating System diff --git a/config/config.conf b/config/config.conf index 33b3cf82..44b03a0b 100644 --- a/config/config.conf +++ b/config/config.conf @@ -717,6 +717,12 @@ image_host="teknik" # Misc Options +# Stdout mode +# Turn off all colors and disables image backend (ASCII/Image). +# Useful for piping into another command. +# Default: 'off' +# Values: 'on', 'off' +stdout="off" # Config version. # diff --git a/neofetch b/neofetch index 9e49c2d6..33460cf8 100755 --- a/neofetch +++ b/neofetch @@ -4198,6 +4198,7 @@ SCREENSHOT: OTHER: --config /path/to/config Specify a path to a custom config file --config none Launch the script without a config file + --stdout Turn off all colors and disables any ASCII/image backend. --help Print this text and exit --version Show neofetch version -v Display error messages. diff --git a/neofetch.1 b/neofetch.1 index 21e96bd8..c31f1c90 100644 --- a/neofetch.1 +++ b/neofetch.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.4. -.TH NEOFETCH "1" "July 2017" "Neofetch 3.2.1-git" "User Commands" +.TH NEOFETCH "1" "August 2017" "Neofetch 3.2.1-git" "User Commands" .SH NAME Neofetch \- A fast, highly customizable system info script .SH SYNOPSIS @@ -304,6 +304,9 @@ Specify a path to a custom config file \fB\-\-config\fR none Launch the script without a config file .TP +\fB\-\-stdout\fR +Turn off all colors and disables any ASCII/image backend. +.TP \fB\-\-help\fR Print this text and exit .TP From e8dc4670e1f676bf9c9e98ae2e45cae1a154c615 Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Fri, 4 Aug 2017 01:29:29 +0700 Subject: [PATCH 6/8] stdout: Disable color_blocks --- neofetch | 1 + 1 file changed, 1 insertion(+) diff --git a/neofetch b/neofetch index 33460cf8..b2eca221 100755 --- a/neofetch +++ b/neofetch @@ -3648,6 +3648,7 @@ stdout() { unset text_padding unset zws unset reset + unset color_blocks } err() { From 9d72eea931e4c28a7a05e8c408feef28e0a49d92 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 4 Aug 2017 11:10:34 +1000 Subject: [PATCH 7/8] stdout: Disable linebreaks --- neofetch | 1 + 1 file changed, 1 insertion(+) diff --git a/neofetch b/neofetch index b2eca221..ce3ca301 100755 --- a/neofetch +++ b/neofetch @@ -3649,6 +3649,7 @@ stdout() { unset zws unset reset unset color_blocks + unset get_line_break } err() { From ab3633ab1cb5cebd7e04d522e52bd9646820a008 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 4 Aug 2017 11:14:26 +1000 Subject: [PATCH 8/8] docs: CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f4abcae..9787a2d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ - Config file now has a `.conf` suffix. - Neofetch now assumes target directories (config file and ASCII directory) at install time, this fixes problems with systems such as NixOS. - `stdout` mode is now reimplemented. + - This mode prints the information in plain text. + - You can use it with `--stdout`. + - Example: https://gist.github.com/dylanaraps/151c205322cf3acae62661b76464a3f7 ## Operating System