KittyKatt / screenFetch

Fetches system/theme information in terminal for Linux desktop screenshots.
GNU General Public License v3.0
3.82k stars 453 forks source link

Screenfetch does not detect AMD GPU when I have both AMD and NVidia #703

Open dllu opened 3 years ago

dllu commented 3 years ago

I'm submitting a ... (check one with "x")

[x] bug report
[ ] new distro request

Bug report

I have both an AMD Radeon RX 6800 and an NVIDIA Geforce GTX Titan Xp in my computer. Screenfetch only reports the latter:

2021-02-08-10:32:10:730542617-maim

whereas neofetch reports both, although the AMD card shows up as "device 73bf".

2021-02-08-10:31:29:153416754-maim

The AMD Radeon RX 6800 is in fact the currently used device, as shown by glxinfo, which shows that AMD SIENNA_CICHLID is being used:

name of display: :0
display: :0  screen: 0
direct rendering: Yes
[... truncated ...]
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: AMD (0x1002)
    Device: AMD SIENNA_CICHLID (DRM 3.40.0, 5.10.13-arch1-2, LLVM 11.0.1) (0x73bf)
    Version: 20.3.4
    Accelerated: yes
    Video memory: 16384MB
    Unified memory: no
    Preferred profile: core (0x1)
    Max core profile version: 4.6
    Max compat profile version: 4.6
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.2

The AMD Radeon RX 6800 is also the bigger and faster of the two GPUs so it is preferred for it to show up if I had to choose one of them.

Previously, when I had only the AMD Radeon RX 6800 (without the NVIDIA Titan Xp), screenfetch correctly shows the AMD card (as SIENNA_CICHLID).

2020-12-25-17:11:35:427733309-grim

IMG_4106

Probably the problem is that there is an elif here:

        if [[ -n "$(PATH="/opt/bin:$PATH" type -p nvidia-smi)" ]]; then
            gpu=$($(PATH="/opt/bin:$PATH" type -p nvidia-smi | cut -f1) -q | awk -F':' '/Product Name/ {gsub(/: /,":"); print $2}' | sed ':a;N;$!ba;s/\n/, /g')
        elif [[ -n "$(PATH="/usr/sbin:$PATH" type -p glxinfo)" && -z "${gpu}" ]]; then
            gpu_info=$($(PATH="/usr/sbin:$PATH" type -p glxinfo | cut -f1) 2>/dev/null)
            gpu=$(grep "OpenGL renderer string" <<< "${gpu_info}" | cut -d ':' -f2 | sed -n -e '1h;2,$H;${g;s/\n/, /g' -e 'p' -e '}')
            gpu="${gpu:1}"
            gpu_info=$(grep "OpenGL vendor string" <<< "${gpu_info}")

which is logically incorrect since having NVIDIA does not preclude having other, better GPUs.

KittyKatt commented 3 years ago

The logic there is gross and absolutely needs revisiting, agreed. I'll try to see what I can do with this.