[+] glxinfo for gpu info (Fix #225)

This commit is contained in:
Azalea
2026-06-03 04:51:58 +00:00
parent 9c280bf1cf
commit 1f85002da5
2 changed files with 49 additions and 13 deletions

View File

@@ -113,10 +113,15 @@ Unsupported on Windows
\fB\-\-gpu_brand\fR on/off
Enable/Disable GPU brand in output. (AMD/NVIDIA/Intel)
.TP
\fB\-\-gpu_backend\fR backend
Which GPU backend to use. (lspci, glxinfo)
.TP
\fB\-\-gpu_type\fR type
Which GPU to display. (all, dedicated, integrated)
.IP
NOTE: This only supports Linux.
.IP
NOTE: glxinfo only reports the GPU attached to the current display.
.TP
\fB\-\-de_version\fR on/off
Show/Hide Desktop Environment version

View File

@@ -404,6 +404,16 @@ cpu_temp="off"
# off: 'HD 7950'
gpu_brand="on"
# Which GPU backend to use
#
# Default: 'lspci'
# Values: 'lspci', 'glxinfo'
# Flag: --gpu_backend
# Supports: Linux
#
# NOTE: 'glxinfo' only reports the GPU attached to the current display.
gpu_backend="lspci"
# Which GPU to display
#
# Default: 'all'
@@ -3706,21 +3716,26 @@ get_gpu() {
case $os in
"Linux")
# Read GPUs into array.
gpu_cmd="$(lspci -mm |
awk -F '\"|\" \"|\\(' \
'/"Display|"3D|"VGA/ {
a[$0] = $1 " " $3 " " ($3 ~ /Intel/ || $(NF-1) ~ /^$|^Device [[:xdigit:]]+$/ ? $4 : $(NF-1))
}
END { for (i in a) {
if (!seen[a[i]]++) {
sub("^[^ ]+ ", "", a[i]);
print a[i]
}
}}')"
if [[ "$gpu_cmd" == "" ]]; then
if [[ "$gpu_backend" == "glxinfo" ]]; then
gpu_cmd="$(glxinfo -B | grep -F 'OpenGL renderer string')"
gpu_cmd="${gpu_cmd/OpenGL renderer string: }"
else
gpu_cmd="$(lspci -mm |
awk -F '\"|\" \"|\\(' \
'/"Display|"3D|"VGA/ {
a[$0] = $1 " " $3 " " ($3 ~ /Intel/ || $(NF-1) ~ /^$|^Device [[:xdigit:]]+$/ ? $4 : $(NF-1))
}
END { for (i in a) {
if (!seen[a[i]]++) {
sub("^[^ ]+ ", "", a[i]);
print a[i]
}
}}')"
if [[ "$gpu_cmd" == "" ]]; then
gpu_cmd="$(glxinfo -B | grep -F 'OpenGL renderer string')"
gpu_cmd="${gpu_cmd/OpenGL renderer string: }"
fi
fi
IFS=$'\n' read -d "" -ra gpus <<< "$gpu_cmd"
@@ -3746,6 +3761,18 @@ get_gpu() {
gpu="$brand $gpu"
;;
*"AMD"*|*"ATI"*|*"Radeon"*)
gpu="${gpu/Advanced Micro Devices, Inc.}"
gpu="${gpu/\[AMD\/ATI\] }"
gpu="${gpu/\[AMD\] }"
gpu="${gpu/OEM }"
gpu="${gpu/ \(*}"
gpu="$(trim "$gpu")"
[[ "$gpu" != *"AMD"* && "$gpu" != *"ATI"* && "$gpu" == *"Radeon"* ]] && \
gpu="AMD $gpu"
;;
*"NVIDIA"*)
gpu="${gpu/*NVIDIA}"
gpu="${gpu/*\[}"
@@ -6851,9 +6878,12 @@ 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_backend backend Which GPU backend to use. (lspci, glxinfo)
--gpu_type type Which GPU to display. (all, dedicated, integrated)
NOTE: This only supports Linux.
NOTE: glxinfo only reports the GPU attached to the
current display.
--de_version on/off Show/Hide Desktop Environment version
--gtk_shorthand on/off Shorten output of gtk theme/icons
@@ -7101,6 +7131,7 @@ get_args() {
"--cpu_brand") cpu_brand="$2" ;;
"--cpu_codename") cpu_codename="$2" ;;
"--gpu_brand") gpu_brand="$2" ;;
"--gpu_backend") gpu_backend="$2" ;;
"--gpu_type") gpu_type="$2" ;;
"--refresh_rate") refresh_rate="$2" ;;
"--de_version") de_version="$2" ;;