Merge pull request #554 from dylanaraps/multi-gpu

GPU: Print each GPU on a different line
This commit is contained in:
Dylan Araps 2016-12-22 13:35:45 +11:00 committed by GitHub
commit 7cce8512c9
3 changed files with 68 additions and 25 deletions

View File

@ -210,6 +210,23 @@ cpu_temp="off"
# off: 'HD 7950' # off: 'HD 7950'
gpu_brand="on" 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 # Resolution

View File

@ -965,35 +965,56 @@ get_cpu_usage() {
get_gpu() { get_gpu() {
case "$os" in case "$os" in
"Linux") "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 # Number the GPUs if more than one exists.
*"advanced"*) (( "${#gpus[@]}" > 1 )) && gpu_num=1
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"
;;
*"nvidia"*) for gpu in "${gpus[@]}"; do
gpu="${gpu//Intel*$'\n'}" # GPU shorthand tests.
gpu="${gpu/*\[}" [[ "$gpu_type" == "dedicated" && "$gpu" =~ (i|I)ntel ]] || \
gpu="${gpu/\]*}" [[ "$gpu_type" == "integrated" && ! "$gpu" =~ (i|I)ntel ]] && \
gpu="NVIDIA $gpu" { unset -v gpu; continue; }
;;
*"virtualbox"*) case "$gpu" in
gpu="VirtualBox Graphics Adapter" *"advanced"*)
;; gpu="${gpu/'[AMD/ATI]' }"
esac gpu="${gpu/'[AMD]' }"
gpu="${gpu/OEM }"
gpu="${gpu/Advanced Micro Devices, Inc.}"
gpu="${gpu/ \/ *}"
gpu="${gpu/*\[}"
gpu="${gpu/\]*}"
gpu="AMD $gpu"
;;
[[ "$gpu" == *"intel"* ]] && \ *"nvidia"*)
gpu="Intel Integrated Graphics" gpu="${gpu/*\[}"
gpu="${gpu/\]*}"
gpu="NVIDIA $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 "${subtitle}${gpu_num}" "$gpu"
gpu_num="$((gpu_num+=1))"
done
return
;; ;;
"Mac OS X") "Mac OS X")
@ -3024,6 +3045,7 @@ INFO
--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_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)
--gpu_type type Which GPU to display. (all, dedicated, integrated)
--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/font/icons output --gtk2 on/off Enable/Disable gtk2 theme/font/icons output
--gtk3 on/off Enable/Disable gtk3 theme/font/icons output --gtk3 on/off Enable/Disable gtk3 theme/font/icons output
@ -3184,6 +3206,7 @@ get_args() {
"--uptime_shorthand") uptime_shorthand="$2" ;; "--uptime_shorthand") uptime_shorthand="$2" ;;
"--cpu_shorthand") cpu_shorthand="$2" ;; "--cpu_shorthand") cpu_shorthand="$2" ;;
"--gpu_brand") gpu_brand="$2" ;; "--gpu_brand") gpu_brand="$2" ;;
"--gpu_type") gpu_type="$2" ;;
"--refresh_rate") refresh_rate="$2" ;; "--refresh_rate") refresh_rate="$2" ;;
"--gtk_shorthand") gtk_shorthand="$2" ;; "--gtk_shorthand") gtk_shorthand="$2" ;;
"--gtk2") gtk2="$2" ;; "--gtk2") gtk2="$2" ;;

View File

@ -68,6 +68,9 @@ Unsupported on Windows
\fB\-\-gpu_brand\fR on/off \fB\-\-gpu_brand\fR on/off
Enable/Disable GPU brand in output. (AMD/NVIDIA/Intel) Enable/Disable GPU brand in output. (AMD/NVIDIA/Intel)
.TP .TP
\fB\-\-gpu_type\fR type
Which GPU to display. (all, dedicated, integrated)
.TP
\fB\-\-gtk_shorthand\fR on/off \fB\-\-gtk_shorthand\fR on/off
Shorten output of gtk theme/icons Shorten output of gtk theme/icons
.TP .TP