From 57d14905bc4377f3c7e26e46f1cc979b0e6ddaec Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 22 Dec 2016 11:17:02 +1100 Subject: [PATCH 1/8] GPU: Print each GPU on a different line --- neofetch | 69 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/neofetch b/neofetch index 56d80d18..1bcacd16 100755 --- a/neofetch +++ b/neofetch @@ -965,35 +965,48 @@ get_cpu_usage() { get_gpu() { case "$os" in "Linux") - gpu="$(lspci -mm | awk -F '\\"|\\" \\"' '/"Display|"3D|"VGA/ {print $3 " " $4}')" + IFS=$'\n' + gpus=($(lspci -mm | awk -F '\\"|\\" \\"' '/"Display|"3D|"VGA/ {print $3 " " $4}')) - case "$gpu" in - *"advanced"*) - gpu="${gpu//Intel*$'\n'}" - gpu="${gpu/'[AMD/ATI]' }" - gpu="${gpu/'[AMD]' }" - gpu="${gpu/OEM }" - gpu="${gpu/Advanced Micro Devices, Inc.}" - gpu="${gpu/ \/ *}" - gpu="${gpu/*\[}" - gpu="${gpu/\]*}" - gpu="AMD $gpu" - ;; + for gpu in "${gpus[@]}"; do + case "$gpu" in + *"advanced"*) + gpu="${gpu/'[AMD/ATI]' }" + gpu="${gpu/'[AMD]' }" + gpu="${gpu/OEM }" + gpu="${gpu/Advanced Micro Devices, Inc.}" + gpu="${gpu/ \/ *}" + gpu="${gpu/*\[}" + gpu="${gpu/\]*}" + gpu="AMD $gpu" + ;; - *"nvidia"*) - gpu="${gpu//Intel*$'\n'}" - gpu="${gpu/*\[}" - gpu="${gpu/\]*}" - gpu="NVIDIA $gpu" - ;; + *"nvidia"*) + gpu="${gpu/*\[}" + gpu="${gpu/\]*}" + gpu="NVIDIA $gpu" + ;; - *"virtualbox"*) - gpu="VirtualBox Graphics Adapter" - ;; - esac + *"intel"*) + gpu="Intel Integrated Graphics" + ;; - [[ "$gpu" == *"intel"* ]] && \ - gpu="Intel Integrated Graphics" + *"virtualbox"*) + gpu="VirtualBox Graphics Adapter" + ;; + esac + + if [[ "$gpu_brand" == "off" ]]; then + gpu="${gpu//AMD }" + gpu="${gpu//NVIDIA }" + gpu="${gpu//Intel }" + fi + + prin "GPU${index:-0}" "$gpu" + index="$((index+=1))" + done + + return ;; "Mac OS X") @@ -1067,9 +1080,9 @@ get_gpu() { esac if [[ "$gpu_brand" == "off" ]]; then - gpu="${gpu/AMD}" - gpu="${gpu/NVIDIA}" - gpu="${gpu/Intel}" + gpu="${gpu//AMD}" + gpu="${gpu//NVIDIA}" + gpu="${gpu//Intel}" fi } From 32116ea67f2ff351b598075ca18a8861fbf4de4c Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 22 Dec 2016 11:26:52 +1100 Subject: [PATCH 2/8] GPU: Don't remove all matches --- neofetch | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/neofetch b/neofetch index 1bcacd16..94ba5243 100755 --- a/neofetch +++ b/neofetch @@ -997,9 +997,9 @@ get_gpu() { esac if [[ "$gpu_brand" == "off" ]]; then - gpu="${gpu//AMD }" - gpu="${gpu//NVIDIA }" - gpu="${gpu//Intel }" + gpu="${gpu/AMD }" + gpu="${gpu/NVIDIA }" + gpu="${gpu/Intel }" fi prin "GPU${index:-0}" "$gpu" @@ -1080,9 +1080,9 @@ get_gpu() { esac if [[ "$gpu_brand" == "off" ]]; then - gpu="${gpu//AMD}" - gpu="${gpu//NVIDIA}" - gpu="${gpu//Intel}" + gpu="${gpu/AMD}" + gpu="${gpu/NVIDIA}" + gpu="${gpu/Intel}" fi } From 7069410ef2cccf9ae46b33dd96fe822b7e91cd54 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 22 Dec 2016 12:47:11 +1100 Subject: [PATCH 3/8] GPU: Only number GPU if more than one exists --- neofetch | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 94ba5243..204ca0e0 100755 --- a/neofetch +++ b/neofetch @@ -968,6 +968,9 @@ get_gpu() { IFS=$'\n' gpus=($(lspci -mm | awk -F '\\"|\\" \\"' '/"Display|"3D|"VGA/ {print $3 " " $4}')) + # Number the GPUs if more than one exists. + [[ "${#gpus[@]}" > 1 ]] && index=0 + for gpu in "${gpus[@]}"; do case "$gpu" in *"advanced"*) @@ -1002,7 +1005,7 @@ get_gpu() { gpu="${gpu/Intel }" fi - prin "GPU${index:-0}" "$gpu" + prin "GPU${index}" "$gpu" index="$((index+=1))" done From 988c0b29a76a7a21e9a2d2083be3170ae8871a0b Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 22 Dec 2016 13:00:16 +1100 Subject: [PATCH 4/8] GPU: Rename index to gpu_num --- neofetch | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/neofetch b/neofetch index 204ca0e0..c44091de 100755 --- a/neofetch +++ b/neofetch @@ -969,7 +969,7 @@ get_gpu() { gpus=($(lspci -mm | awk -F '\\"|\\" \\"' '/"Display|"3D|"VGA/ {print $3 " " $4}')) # Number the GPUs if more than one exists. - [[ "${#gpus[@]}" > 1 ]] && index=0 + [[ "${#gpus[@]}" > 1 ]] && gpu_num=0 for gpu in "${gpus[@]}"; do case "$gpu" in @@ -1005,8 +1005,8 @@ get_gpu() { gpu="${gpu/Intel }" fi - prin "GPU${index}" "$gpu" - index="$((index+=1))" + prin "GPU${gpu_num}" "$gpu" + gpu_num="$((gpu_num+=1))" done return From d74a7ce4e9e5852b2decb22cafa4c7f729ed02ec Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 22 Dec 2016 13:01:04 +1100 Subject: [PATCH 5/8] GPU: Use arithmetic test --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index c44091de..26b7f885 100755 --- a/neofetch +++ b/neofetch @@ -969,7 +969,7 @@ get_gpu() { gpus=($(lspci -mm | awk -F '\\"|\\" \\"' '/"Display|"3D|"VGA/ {print $3 " " $4}')) # Number the GPUs if more than one exists. - [[ "${#gpus[@]}" > 1 ]] && gpu_num=0 + (( "${#gpus[@]}" > 1 )) && gpu_num=0 for gpu in "${gpus[@]}"; do case "$gpu" in From 37d3b9f9a42ecc7b25476ad355baa56c7af465db Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 22 Dec 2016 13:04:43 +1100 Subject: [PATCH 6/8] GPU: Use $subtitle with prin --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 51bdc2d2..f9da4be2 100755 --- a/neofetch +++ b/neofetch @@ -1005,7 +1005,7 @@ get_gpu() { gpu="${gpu/Intel }" fi - prin "GPU${gpu_num}" "$gpu" + prin "${subtitle}${gpu_num}" "$gpu" gpu_num="$((gpu_num+=1))" done From ab4edd42cf635888c9bf4e33ccf68778f5ed9e13 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 22 Dec 2016 13:19:25 +1100 Subject: [PATCH 7/8] GPU: Count from 1, Add $gpu_show to change which GPUs are displayed --- neofetch | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/neofetch b/neofetch index f9da4be2..cfcc2b29 100755 --- a/neofetch +++ b/neofetch @@ -969,9 +969,14 @@ get_gpu() { gpus=($(lspci -mm | awk -F '\\"|\\" \\"' '/"Display|"3D|"VGA/ {print $3 " " $4}')) # Number the GPUs if more than one exists. - (( "${#gpus[@]}" > 1 )) && gpu_num=0 + (( "${#gpus[@]}" > 1 )) && gpu_num=1 for gpu in "${gpus[@]}"; do + # GPU shorthand tests. + [[ "$gpu_show" == "dedicated" && "$gpu" =~ (i|I)ntel ]] || \ + [[ "$gpu_show" == "integrated" && ! "$gpu" =~ (i|I)ntel ]] && \ + { unset -v gpu; continue; } + case "$gpu" in *"advanced"*) gpu="${gpu/'[AMD/ATI]' }" From f5d2aac5aa442ed5b5b7174841f4ff9dfc391b55 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 22 Dec 2016 13:23:48 +1100 Subject: [PATCH 8/8] GPU: Add --gpu_type --- config/config | 17 +++++++++++++++++ neofetch | 6 ++++-- neofetch.1 | 3 +++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/config/config b/config/config index b1ed368f..66d859c1 100644 --- a/config/config +++ b/config/config @@ -210,6 +210,23 @@ cpu_temp="off" # off: 'HD 7950' gpu_brand="on" +# Which GPU to display +# +# Default: 'all' +# Values: 'all', 'dedicated', 'integrated' +# Flag: --gpu_type +# +# Example: +# all: +# GPU1: AMD HD 7950 +# GPU2: Intel Integrated Graphics +# +# dedicated: +# GPU1: AMD HD 7950 +# +# integrated: +# GPU1: Intel Integrated Graphics +gpu_type="all" # Resolution diff --git a/neofetch b/neofetch index cfcc2b29..e40c099c 100755 --- a/neofetch +++ b/neofetch @@ -973,8 +973,8 @@ get_gpu() { for gpu in "${gpus[@]}"; do # GPU shorthand tests. - [[ "$gpu_show" == "dedicated" && "$gpu" =~ (i|I)ntel ]] || \ - [[ "$gpu_show" == "integrated" && ! "$gpu" =~ (i|I)ntel ]] && \ + [[ "$gpu_type" == "dedicated" && "$gpu" =~ (i|I)ntel ]] || \ + [[ "$gpu_type" == "integrated" && ! "$gpu" =~ (i|I)ntel ]] && \ { unset -v gpu; continue; } case "$gpu" in @@ -3045,6 +3045,7 @@ INFO --refresh_rate on/off Whether to display the refresh rate of each monitor Unsupported on Windows --gpu_brand on/off Enable/Disable GPU brand in output. (AMD/NVIDIA/Intel) + --gpu_type type Which GPU to display. (all, dedicated, integrated) --gtk_shorthand on/off Shorten output of gtk theme/icons --gtk2 on/off Enable/Disable gtk2 theme/font/icons output --gtk3 on/off Enable/Disable gtk3 theme/font/icons output @@ -3205,6 +3206,7 @@ get_args() { "--uptime_shorthand") uptime_shorthand="$2" ;; "--cpu_shorthand") cpu_shorthand="$2" ;; "--gpu_brand") gpu_brand="$2" ;; + "--gpu_type") gpu_type="$2" ;; "--refresh_rate") refresh_rate="$2" ;; "--gtk_shorthand") gtk_shorthand="$2" ;; "--gtk2") gtk2="$2" ;; diff --git a/neofetch.1 b/neofetch.1 index b1494b4b..2136425d 100644 --- a/neofetch.1 +++ b/neofetch.1 @@ -68,6 +68,9 @@ Unsupported on Windows \fB\-\-gpu_brand\fR on/off Enable/Disable GPU brand in output. (AMD/NVIDIA/Intel) .TP +\fB\-\-gpu_type\fR type +Which GPU to display. (all, dedicated, integrated) +.TP \fB\-\-gtk_shorthand\fR on/off Shorten output of gtk theme/icons .TP