How to configure an application to always run with DRI_PRIME=1 set? Is there an other way besides terminal?

Solution 1:

Here is a little light reading on environment variables for those sleepless nights, but to cut to the chase, I quote:

"A suitable file for environment variable settings that affect the system as a whole (rather than just a particular user) is /etc/environment.

This file is specifically meant for system-wide environment variable settings. It is not a script file, but rather consists of assignment expressions, one per line."

So... Inserting your assignment DRI_PRIME=1 into /etc/environment and then restarting should do what you're asking.

Solution 2:

There is now a PrefersNonDefaultGPU .desktop file key. It was merged into the spec on 2020-04-27 and GNOME has just received the first implementation 3 hours ago and you may be able to use it after gnome-shell version 3.37.1.

Solution 3:

You can set an environment variable system-wide by setting it in /etc/default/locale. This will set it for all users, so you want to be sure that's what you really want. Keep in mind that local settings (such as in .bashrc) will override the system-wide setting.