From cc9095ccd5bcd31383fb51d754cd998d118e16d6 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 25 Oct 2016 10:39:56 +1100 Subject: [PATCH 1/6] Refactor GPU --- neofetch | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/neofetch b/neofetch index 214fb195..bd2f45b7 100755 --- a/neofetch +++ b/neofetch @@ -987,12 +987,12 @@ getcpu_usage() { getgpu() { case "$os" in "Linux") - gpu="$(PATH="/sbin:$PATH" lspci | grep -F "3D")" + gpu="$(PATH="/sbin:$PATH" lspci -mm | awk -F '\\"|\\" \\"' '/3D|VGA/ {print $3 " " $4}')" # If a GPU with a prefix of '3D' doesn't exist # fallback to looking for a prefix of 'VGA' - [ -z "$gpu" ] && \ - gpu="$(PATH="/sbin:$PATH" lspci | grep -F "VGA")" + # [ -z "$gpu" ] && \ + # gpu="$(PATH="/sbin:$PATH" lspci | grep -F "VGA")" gpu="${gpu//??':'??'.'?}" @@ -2427,7 +2427,7 @@ info() { eval output="\$${1}" else - "get$2" 2>/dev/null + time "get$2" 2>/dev/null eval output="\$${2}" fi From 0177837f69c02d31e41d98be20798f91149266d4 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 26 Oct 2016 22:48:20 +1100 Subject: [PATCH 2/6] GPU: Start rewrite --- neofetch | 56 +++++++------------------------------------------------- 1 file changed, 7 insertions(+), 49 deletions(-) diff --git a/neofetch b/neofetch index bd2f45b7..204e932e 100755 --- a/neofetch +++ b/neofetch @@ -989,63 +989,25 @@ getgpu() { "Linux") gpu="$(PATH="/sbin:$PATH" lspci -mm | awk -F '\\"|\\" \\"' '/3D|VGA/ {print $3 " " $4}')" - # If a GPU with a prefix of '3D' doesn't exist - # fallback to looking for a prefix of 'VGA' - # [ -z "$gpu" ] && \ - # gpu="$(PATH="/sbin:$PATH" lspci | grep -F "VGA")" - - gpu="${gpu//??':'??'.'?}" - - # Count the number of GPUs - count="$(printf "%s" "$gpu" | uniq -c)" - count="${count/ VGA*}" - count="${count/ 3D*}" - - # If there's more than one gpu - # Display the count. - if [ "$count" -gt 1 ]; then - count=" x $count" - else - unset count - fi - - # Format the output - gpu="${gpu/* VGA compatible controller: }" - gpu="${gpu/* 3D controller: }" - gpu="${gpu/(rev*)}" - gpu="${gpu/\[}" - gpu="${gpu/\]}" - case "$gpu" in - intel*) - gpu="Intel Integrated Graphics" - ;; + intel*) gpu="Intel Integrated Graphics" ;; advanced*) - gpu="${gpu/Advanced Micro Devices, Inc\. }" gpu="${gpu/'[AMD/ATI]' }" - gpu="${gpu/Tahiti PRO}" - gpu="${gpu/XTX}" - gpu="${gpu/ OEM}" - gpu="${gpu/*Radeon/Radeon}" - - brand="AMD " + gpu="${gpu/'[AMD]' }" + gpu="${gpu/*\[}" + gpu="${gpu/\]*}" ;; nvidia*) - gpu="${gpu/NVIDIA Corporation }" - gpu="${gpu/G????M }" - gpu="${gpu/G???? }" - - brand="NVIDIA " + gpu="${gpu/*\[}" + gpu="${gpu/\]*}" ;; *virtualbox*) gpu="VirtualBox Graphics Adapter" ;; esac - - gpu="${brand}${gpu}" ;; "Mac OS X") @@ -1137,11 +1099,7 @@ getgpu() { case "$gpu_shorthand" in "on" | "tiny") gpu="${gpu// Rev\. ?}" - gpu="${gpu//AMD*\/ATI\]/AMD}" - gpu="${gpu// Tahiti}" - gpu="${gpu// PRO}" gpu="${gpu// OEM}" - gpu="${gpu// Mars}" gpu="${gpu// Series}" gpu="${gpu// Controller}" gpu="${gpu/\/*}" @@ -2427,7 +2385,7 @@ info() { eval output="\$${1}" else - time "get$2" 2>/dev/null + "get$2" 2>/dev/null eval output="\$${2}" fi From b2d17711f97b7a19d4c7aacf9e1c09c98914ad0b Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 26 Oct 2016 23:16:57 +1100 Subject: [PATCH 3/6] GPU: Add brand --- neofetch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/neofetch b/neofetch index 204e932e..2c3b5f0b 100755 --- a/neofetch +++ b/neofetch @@ -997,11 +997,13 @@ getgpu() { gpu="${gpu/'[AMD]' }" gpu="${gpu/*\[}" gpu="${gpu/\]*}" + gpu="AMD $gpu" ;; nvidia*) gpu="${gpu/*\[}" gpu="${gpu/\]*}" + gpu="NVIDIA $gpu" ;; *virtualbox*) @@ -1119,8 +1121,6 @@ getgpu() { gpu="${gpu/NVIDIA}" gpu="${gpu/Intel}" fi - - gpu="${gpu}${count}" } # }}} From 4e7955bc94bbcb259f0d85f0951eeb4783960544 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 26 Oct 2016 23:22:08 +1100 Subject: [PATCH 4/6] Cache GPU output --- neofetch | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/neofetch b/neofetch index 2c3b5f0b..7675029d 100755 --- a/neofetch +++ b/neofetch @@ -987,29 +987,35 @@ getcpu_usage() { getgpu() { case "$os" in "Linux") - gpu="$(PATH="/sbin:$PATH" lspci -mm | awk -F '\\"|\\" \\"' '/3D|VGA/ {print $3 " " $4}')" + # Use cache if it exists + if [ -f "/tmp/neofetch/gpu" ]; then + source "/tmp/neofetch/gpu" + else + gpu="$(PATH="/sbin:$PATH" lspci -mm | awk -F '\\"|\\" \\"' '/3D|VGA/ {print $3 " " $4}')" - case "$gpu" in - intel*) gpu="Intel Integrated Graphics" ;; + case "$gpu" in + intel*) gpu="Intel Integrated Graphics" ;; - advanced*) - gpu="${gpu/'[AMD/ATI]' }" - gpu="${gpu/'[AMD]' }" - gpu="${gpu/*\[}" - gpu="${gpu/\]*}" - gpu="AMD $gpu" - ;; + advanced*) + gpu="${gpu/'[AMD/ATI]' }" + gpu="${gpu/'[AMD]' }" + gpu="${gpu/*\[}" + gpu="${gpu/\]*}" + gpu="AMD $gpu" + ;; - nvidia*) - gpu="${gpu/*\[}" - gpu="${gpu/\]*}" - gpu="NVIDIA $gpu" - ;; + nvidia*) + gpu="${gpu/*\[}" + gpu="${gpu/\]*}" + gpu="NVIDIA $gpu" + ;; - *virtualbox*) - gpu="VirtualBox Graphics Adapter" - ;; - esac + *virtualbox*) + gpu="VirtualBox Graphics Adapter" + ;; + esac + cache "gpu" "$gpu" "/tmp" + fi ;; "Mac OS X") From 8cbf7e7febaf8f14f322c8c4fb6b3f63a4715bd1 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 26 Oct 2016 23:41:17 +1100 Subject: [PATCH 5/6] Remove GPU shorthand --- README.md | 1 - config/config | 4 ---- neofetch | 21 +-------------------- neofetch.1 | 3 --- 4 files changed, 1 insertion(+), 28 deletions(-) diff --git a/README.md b/README.md index 04352c52..b24fddeb 100644 --- a/README.md +++ b/README.md @@ -443,7 +443,6 @@ alias neofetch2="neofetch \ --uptime_shorthand on/off Shorten the output of uptime (tiny, on, off) --refresh_rate on/off Whether to display the refresh rate of each monitor Unsupported on Windows - --gpu_shorthand on/off Shorten the output of GPU (tiny, on, off) --gpu_brand on/off Enable/Disable GPU brand in output. (AMD/NVIDIA/Intel) --gtk_shorthand on/off Shorten output of gtk theme/icons --gtk2 on/off Enable/Disable gtk2 theme/icons output diff --git a/config/config b/config/config index eeecf851..c02fb537 100644 --- a/config/config +++ b/config/config @@ -128,10 +128,6 @@ cpu_temp="off" # GPU -# Shorten output of the getgpu funcion -# --gpu_shorthand on, off, tiny -gpu_shorthand="on" - # Enable/Disable GPU Brand # --gpu_brand on, off gpu_brand="on" diff --git a/neofetch b/neofetch index 7675029d..baa1279e 100755 --- a/neofetch +++ b/neofetch @@ -1001,6 +1001,7 @@ getgpu() { gpu="${gpu/'[AMD]' }" gpu="${gpu/*\[}" gpu="${gpu/\]*}" + gpu="${gpu/\/*}" gpu="AMD $gpu" ;; @@ -1104,24 +1105,6 @@ getgpu() { ;; esac - case "$gpu_shorthand" in - "on" | "tiny") - gpu="${gpu// Rev\. ?}" - gpu="${gpu// OEM}" - gpu="${gpu// Series}" - gpu="${gpu// Controller}" - gpu="${gpu/\/*}" - - case "$gpu_shorthand" in - "tiny") - gpu="${gpu/Graphics }" - gpu="${gpu/GeForce }" - gpu="${gpu/Radeon }" - ;; - esac - ;; - esac - if [ "$gpu_brand" == "off" ]; then gpu="${gpu/AMD}" gpu="${gpu/NVIDIA}" @@ -3001,7 +2984,6 @@ usage() { cat << EOF --uptime_shorthand on/off Shorten the output of uptime (tiny, on, off) --refresh_rate on/off Whether to display the refresh rate of each monitor Unsupported on Windows - --gpu_shorthand on/off Shorten the output of GPU (tiny, on, off) --gpu_brand on/off Enable/Disable GPU brand in output. (AMD/NVIDIA/Intel) --gtk_shorthand on/off Shorten output of gtk theme/icons --gtk2 on/off Enable/Disable gtk2 theme/icons output @@ -3129,7 +3111,6 @@ getargs() { --kernel_shorthand) kernel_shorthand="$2" ;; --uptime_shorthand) uptime_shorthand="$2" ;; --cpu_shorthand) cpu_shorthand="$2" ;; - --gpu_shorthand) gpu_shorthand="$2" ;; --gpu_brand) gpu_brand="$2" ;; --refresh_rate) refresh_rate="$2" ;; --gtk_shorthand) gtk_shorthand="$2" ;; diff --git a/neofetch.1 b/neofetch.1 index 5fa7c980..d69fbe20 100644 --- a/neofetch.1 +++ b/neofetch.1 @@ -64,9 +64,6 @@ Whether to display the refresh rate of each monitor .br Note: Unsupported on Windows .TP -.B \--gpu_shorthand 'on/off' -Shorten the output of GPU (tiny, on, off) -.TP .B \--gpu_brand on/off Enable/Disable GPU brand in output. (AMD/NVIDIA/Intel) .TP From 64b8e02812c2c10741e8c72c1559644eb9d5dadc Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 26 Oct 2016 23:50:54 +1100 Subject: [PATCH 6/6] Fix --- neofetch | 1 + 1 file changed, 1 insertion(+) diff --git a/neofetch b/neofetch index baa1279e..0a2befc4 100755 --- a/neofetch +++ b/neofetch @@ -3190,6 +3190,7 @@ getargs() { --clean) rm -rf "$thumbnail_dir" rm -rf "/Library/Caches/neofetch/" + rm -rf "/tmp/neofetch/" exit ;;