psensor icon indicating copy to clipboard operation
psensor copied to clipboard

NVIDIA Wayland Support

Open shawndfernandes opened this issue 1 month ago • 0 comments

NVIDIA NVCTRL does not work on Ubuntu-Walyand, was wondering if nvtop and nvitop or nvidia-smi can be integrated

RCA -> NVIDIA has issue with Wayland on detecting the Nvidia Control Extension and fails in this function → XNVCTRLQueryExtension

[ERR] nvctrl: Failed to retrieve NVIDIA information.

#include <iostream>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "NVCtrl/NVCtrl.h"
#include "NVCtrl/NVCtrlLib.h"

int main() {
    Display *dpy;
    int eventBase, errorBase;

    // Open a connection to the X server
    dpy = XOpenDisplay(NULL);

    if (!dpy) {
        std::cerr << "Error: Could not open X display." << std::endl;
        return 1;
    }

    std::cout << "Connection to X server established." << std::endl;

    // Query for the NV-CONTROL extension
    if (XNVCTRLQueryExtension(dpy, &eventBase, &errorBase) == True) {
        std::cout << "NVIDIA NV-CONTROL extension is present." << std::endl;
        std::cout << "  Event base: " << eventBase << std::endl;
        std::cout << "  Error base: " << errorBase << std::endl;

        // You can now use other NVCtrl functions, like querying attribute values
        // for specific screens/GPUs.
    } else {
        std::cout << "NVIDIA NV-CONTROL extension is NOT present or not supported." << std::endl;
    }

    // Close the X server connection
    XCloseDisplay(dpy);

    return 0;
}
</code>

### Compilation and Execution

1.  **Save** the code above as `nvctrl_test.cpp`.
2.  **Compile** it using `g++` and link against the necessary libraries (`lX11` and `lXNVCtrl`):
    ```bash
    g++ nvctrl_test.cpp -o nvctrl_test -lX11 -lXNVCtrl
    ```
3.  **Run** the executable:
    ```bash
    ./nvctrl_test
    ```

The output will confirm whether the NV-CONTROL extension was successfully found on your system.

shawndfernandes avatar Dec 14 '25 22:12 shawndfernandes