NVIDIA / nvidia-settings

NVIDIA driver control panel
http://www.nvidia.com/object/unix.html
GNU General Public License v2.0
296 stars 77 forks source link

Can't produce a valid query/assignment specification in the CLI #95

Open gusrondina opened 1 year ago

gusrondina commented 1 year ago

Hello. I'm trying to change the DigitalVibrance attribute of the display attached to my GPU but I can't seem to be able to produce a valid CLI assignment specification. Even to just query this specific attribute I can't craft a spec that works.

Querying works with -q all:

$ nvidia-settings -q all
...
 Attribute 'DigitalVibrance' (laptop:1[gpu:0]; display device: TV-0): 0.
    The valid values for 'DigitalVibrance' are in the range -1024 - 1023 (inclusive).
    'DigitalVibrance' is display device specific.
    'DigitalVibrance' can use the following target types: X Screen, GPU, Display Device.
...

Based on the output above and on the format suggested by the --help, i.e., {DISPLAY}/{attribute name}[{display devices}], I tried:

$ nvidia-settings -q laptop:1[gpu:0]/DigitalVibrance[TV-0]

ERROR: Error resolving target specification 'gpu-0' (No targets match target specification), specified in query 'laptop:1[gpu-0]/DigitalVibrance[TV-0]'.

But no success. So I tried different things with the following script:

#!/bin/bash
# query_gpu.sh
set -u
attribute="DigitalVibrance"
for host in "" "laptop" "localhost" "$(hostname -s)"; do
    for display in "0" "1"; do
        for target_type in "DPY" "gpu" "GPU" "gpu-0" "GPU-0"; do
            for target_id in "HDMI-1-0" "0" "1"; do
                for display_device in "TV-0" "HDMI-1-0" "DPY-0" ""; do
                    if [ -z "${display_device}" ]; then
                        query="${host}:${display}[${target_type}:${target_id}]/${attribute}"
                    else
                        query="${host}:${display}[${target_type}:${target_id}]/${attribute}[${display_device}]"
                    fi
                    echo "#### Trying: ${query}"
                    nvidia-settings -q "${query}"
                done
            done
        done
    done
done

None worked, but some interesting results: querying with these targets does not produce an error but also no output:

$ nvidia-settings -q [GPU:0]/DigitalVibrance

$ nvidia-settings -q [gpu:0]/DigitalVibrance

If something other than GPU:0 or gpu:0 is given as targets then an error is produced. Strangely enough, specifying the host with the "correct" targets as above also doesn't work:

$ nvidia-settings -q laptop:1[GPU-0]/DigitalVibrance

ERROR: Error resolving target specification 'GPU-0' (No targets match target specification), specified in query 'laptop:1[GPU-0]/DigitalVibrance'.

But it doesn't complain if we omit the host:

$ nvidia-settings -q :1[GPU-0]/DigitalVibrance

$ nvidia-settings -q :1[gpu-0]/DigitalVibrance

What suggests that it might be a bug: everything works as expected in the GUI and if I set the DigitalVibrance to something, e.g., -100, and then save the configuration, then the format in which is saved is not a valid query. That is:

$ grep DigitalVibrance .nvidia-settings-rc 
[DPY:HDMI-1-0]/DigitalVibrance=-100
$ nvidia-settings -q [DPY:HDMI-1-0]/DigitalVibrance

ERROR: Error resolving target specification 'DPY:HDMI-1-0' (No targets match
       target specification), specified in query
       '[DPY:HDMI-1-0]/DigitalVibrance'.

Information about the system:

The output of -q gpus and -q all is attached, also the output of the small shell script shown above.

script-query-gpu-output.txt nvidia-settings-query-all.txt nvidia-settings-query-gpus.txt