* Only poll NVIDIA GPUs which are awake.
* Slow down polling if an NVIDIA GPU can sleep.
If an NVIDIA GPU is eligible to sleep, i.e. runtime D3 sleep is enabled
and no processes except GNOME or X.org are running, then don't poll the
GPU for at least another 30 seconds.
* NVIDIA: Check for X.org correctly on most distros.
If a distro is naming X.org differently than these common and sensible
names, then we can't detect or account for that in any way unfortunately
* Show N/A instead when NVIDIA GPU is sleeping.
Since the card list is populated only in constructor, to update it we
had to toggle "Nvidia" switch `on`->`off`->`on`.
The fix is to get the temperature along with the card name in one
`nvidia-smi` call.
Also some code cleanup was made, removed old unused code.
Fixes#241
Signed-off-by: Pavel Artsishevsky <polter.rnd@gmail.com>
At least on one Intel systems (i7-8700K/delidded/watercooled) the
display of the GPU temperature of NVIDIA cards caused perceptible spikes
in CPU utilization, frequency and temperature of individual cores.
This was eventually tracked down to nvidia-settings being substantially
slower and, more importantly, computationally intensive than nvidia-smi.
Switch the nvidiaUtil implementation to use nvidia-smi. In the process,
simplify the label parsing and label vs. temperature code because
nvidia-smi allows us greater control over the output.
According to warning given today with gnome 3.30:
"Some code called array.toString() on a Uint8Array instance. Previously this would have interpreted the bytes of the array as a string, but that is nonstandard. In the future this will return the bytes as comma-separated digits. For the time being, the old behavior has been preserved, but please fix your code anyway to explicitly call ByteArray.toString(array)."