On x11, installing psensor shows Nvidia GPU temps without running sensors-detect or any other setup. But in Wayland it fails to retrieve information from nvctrl and doesn’t show Nvidia temps
Terminal when running psensor:
[ERR] nvctrl: Failed to retrieve NVIDIA information
Acer nitro 5
Ryzen 7 5800H
RTX 3060
KDE
NVIDIA has issue with Wayland on detecting the Nvidia Control Extension and fails in this function → XNVCTRLQueryExtension
Alternatives include nvtop and nvitop and nvidia-smi
Test C++ code for → XNVCTRLQueryExtension
#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.