[510.73] Setting up OpenGL rendering settings with PRIME

I recently did a fresh reinstall of KUbuntu to version 22.04 on my laptop, and it comes with nvidia driver 510.73.

This version presents a PRIME on-demand functionality, which I understand allows to run only graphic intensive applications on the NVIDIA GPU while using the iGPU for the rest and saving power.

I think I managed to have it work to run games like Crusader Kings III and Stellaris.

However, I always had the habit of setting the OpenGL rendering parameters to High performance instead of the default High quality, either with the Nvidia Settings GUI or by issuing

nvidia-settings -a OpenGLImageSettings=3

Now I want to combine both. I reimplemented a prime-run script, as it is absent from my distro, in the following form :


export __VK_LAYER_NV_optimus=NVIDIA_only
nvidia-settings -a OpenGLImageSettings=3

However, this gives an error : ERROR: Error resolving target specification '' (No targets match target specification), specified in query 'OpenGLImageSettings'. and I am not sure it does anything useful before running the application.

How can I ensure that applications run on the Nvidia GPU use the High Performance setting for openGL ?