I'm learning godot with a laptop that has AMD discrete GPU. My OS is Arch Linux so if I want to use discrete GPU I have to set system environment variable DRI_PRIME=1 temporarily. This can be easily done with pygame, just add following code:

import os

os.environ['DRI_PRIME'] = '1'

The game will launch using discrete GPU.

But if I want to do that in godot, I have to run it fully in discrete GPU, which means I have to use command DRI_PRIME=1 godot to launch it. It's now using discrete GPU to run game, but it takes 4-5 seconds to react to my input when I switch back from tutorial webpage from browser. That's because the discrete GPU will hang when switching out of godot, and I have to wait for it to respond. It will waste a lot of time if I frequently switch between godot and browser.

Is there any configuration to temporarily set system environment variable only in 'play' mode inside godot editor?

  • \$\begingroup\$ I don't think what you want is possible because you likely need to set that variable before Godot starts rendering (before it creates a window). Works in pygame because you do it before the pygame loop. You need the env variable to be set early enough that the rendering system can read it when creating the window. \$\endgroup\$
    – idbrii
    Commented Jul 30, 2023 at 21:22

1 Answer 1


Seems the solution that works so far is to write my own shell script.

Here's the script:


export DRI_PRIME=1

if [[ $# -ge 1 ]]; then
    if [[ -f 'Scenes/'$1'.tscn' ]]; then
        godot -d Scenes/$1.tscn --position 400,300;
        echo 'File doesn'\''t exist!';
    echo 'Please specify main scene!';

I wish godot team to provide cmdline feature inside editor ( / __ \ )

  • 1
    \$\begingroup\$ Sounds like you stumbled into something Godot does not have, but you wish it had. Consider writing a proposal: github.com/godotengine/godot-proposals \$\endgroup\$
    – Theraot
    Commented Sep 5, 2021 at 22:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .