Merge pull request #398 from dylanaraps/gpu

GPU: [Linux] Rewrite GPU
This commit is contained in:
Dylan Araps 2016-10-26 23:50:57 +11:00 committed by GitHub
commit 785a22520b
4 changed files with 29 additions and 91 deletions

View File

@ -443,7 +443,6 @@ alias neofetch2="neofetch \
--uptime_shorthand on/off Shorten the output of uptime (tiny, on, off) --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 --refresh_rate on/off Whether to display the refresh rate of each monitor
Unsupported on Windows 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) --gpu_brand on/off Enable/Disable GPU brand in output. (AMD/NVIDIA/Intel)
--gtk_shorthand on/off Shorten output of gtk theme/icons --gtk_shorthand on/off Shorten output of gtk theme/icons
--gtk2 on/off Enable/Disable gtk2 theme/icons output --gtk2 on/off Enable/Disable gtk2 theme/icons output

View File

@ -128,10 +128,6 @@ cpu_temp="off"
# GPU # GPU
# Shorten output of the getgpu funcion
# --gpu_shorthand on, off, tiny
gpu_shorthand="on"
# Enable/Disable GPU Brand # Enable/Disable GPU Brand
# --gpu_brand on, off # --gpu_brand on, off
gpu_brand="on" gpu_brand="on"

View File

@ -900,65 +900,36 @@ getcpu_usage() {
getgpu() { getgpu() {
case "$os" in case "$os" in
"Linux") "Linux")
gpu="$(PATH="/sbin:$PATH" lspci | grep -F "3D")" # Use cache if it exists
if [ -f "/tmp/neofetch/gpu" ]; then
# If a GPU with a prefix of '3D' doesn't exist source "/tmp/neofetch/gpu"
# 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 else
unset count gpu="$(PATH="/sbin:$PATH" lspci -mm | awk -F '\\"|\\" \\"' '/3D|VGA/ {print $3 " " $4}')"
fi
# Format the output
gpu="${gpu/* VGA compatible controller: }"
gpu="${gpu/* 3D controller: }"
gpu="${gpu/(rev*)}"
gpu="${gpu/\[}"
gpu="${gpu/\]}"
case "$gpu" in case "$gpu" in
intel*) intel*) gpu="Intel Integrated Graphics" ;;
gpu="Intel Integrated Graphics"
;;
advanced*) advanced*)
gpu="${gpu/Advanced Micro Devices, Inc\. }"
gpu="${gpu/'[AMD/ATI]' }" gpu="${gpu/'[AMD/ATI]' }"
gpu="${gpu/Tahiti PRO}" gpu="${gpu/'[AMD]' }"
gpu="${gpu/XTX}" gpu="${gpu/*\[}"
gpu="${gpu/ OEM}" gpu="${gpu/\]*}"
gpu="${gpu/*Radeon/Radeon}" gpu="${gpu/\/*}"
gpu="AMD $gpu"
brand="AMD "
;; ;;
nvidia*) nvidia*)
gpu="${gpu/NVIDIA Corporation }" gpu="${gpu/*\[}"
gpu="${gpu/G????M }" gpu="${gpu/\]*}"
gpu="${gpu/G???? }" gpu="NVIDIA $gpu"
brand="NVIDIA "
;; ;;
*virtualbox*) *virtualbox*)
gpu="VirtualBox Graphics Adapter" gpu="VirtualBox Graphics Adapter"
;; ;;
esac esac
cache "gpu" "$gpu" "/tmp"
gpu="${brand}${gpu}" fi
;; ;;
"Mac OS X") "Mac OS X")
@ -1026,35 +997,11 @@ getgpu() {
;; ;;
esac esac
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/\/*}"
case "$gpu_shorthand" in
"tiny")
gpu="${gpu/Graphics }"
gpu="${gpu/GeForce }"
gpu="${gpu/Radeon }"
;;
esac
;;
esac
if [ "$gpu_brand" == "off" ]; then if [ "$gpu_brand" == "off" ]; then
gpu="${gpu/AMD}" gpu="${gpu/AMD}"
gpu="${gpu/NVIDIA}" gpu="${gpu/NVIDIA}"
gpu="${gpu/Intel}" gpu="${gpu/Intel}"
fi fi
gpu="${gpu}${count}"
} }
# }}} # }}}
@ -2920,7 +2867,6 @@ usage() { cat << EOF
--uptime_shorthand on/off Shorten the output of uptime (tiny, on, off) --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 --refresh_rate on/off Whether to display the refresh rate of each monitor
Unsupported on Windows 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) --gpu_brand on/off Enable/Disable GPU brand in output. (AMD/NVIDIA/Intel)
--gtk_shorthand on/off Shorten output of gtk theme/icons --gtk_shorthand on/off Shorten output of gtk theme/icons
--gtk2 on/off Enable/Disable gtk2 theme/icons output --gtk2 on/off Enable/Disable gtk2 theme/icons output
@ -3046,7 +2992,6 @@ getargs() {
--kernel_shorthand) kernel_shorthand="$2" ;; --kernel_shorthand) kernel_shorthand="$2" ;;
--uptime_shorthand) uptime_shorthand="$2" ;; --uptime_shorthand) uptime_shorthand="$2" ;;
--cpu_shorthand) cpu_shorthand="$2" ;; --cpu_shorthand) cpu_shorthand="$2" ;;
--gpu_shorthand) gpu_shorthand="$2" ;;
--gpu_brand) gpu_brand="$2" ;; --gpu_brand) gpu_brand="$2" ;;
--refresh_rate) refresh_rate="$2" ;; --refresh_rate) refresh_rate="$2" ;;
--gtk_shorthand) gtk_shorthand="$2" ;; --gtk_shorthand) gtk_shorthand="$2" ;;
@ -3124,6 +3069,7 @@ getargs() {
--clean) --clean)
rm -rf "$thumbnail_dir" rm -rf "$thumbnail_dir"
rm -rf "/Library/Caches/neofetch/" rm -rf "/Library/Caches/neofetch/"
rm -rf "/tmp/neofetch/"
exit exit
;; ;;

View File

@ -64,9 +64,6 @@ Whether to display the refresh rate of each monitor
.br .br
Note: Unsupported on Windows Note: Unsupported on Windows
.TP .TP
.B \--gpu_shorthand 'on/off'
Shorten the output of GPU (tiny, on, off)
.TP
.B \--gpu_brand on/off .B \--gpu_brand on/off
Enable/Disable GPU brand in output. (AMD/NVIDIA/Intel) Enable/Disable GPU brand in output. (AMD/NVIDIA/Intel)
.TP .TP