How to set up system wide variable on log in to fix slow launch of chromium based apps on non-nvidia devices

I am having a problem with launching chromium based apps on my second device without nvidia gpu. It takes very long to launch.
I found out that running for example VSCode like this fixes the issue:

$ VK_DRIVER_FILES= code

My idea was to create a script, that would check on each login whether a intel gpu is present (or maybe better if nvidia gpu is not present). The script works like this:

#!/bin/bash

string=$(glxinfo | grep 'Vendor')

if [[ "$string" =~ .+Intel.+ ]]; then
    echo "True"
    export VK_DRIVER_FILES= 
else
    echo "False"
fi

Unfortunatelly when I source this script, the variable only exists in the current terminal session and not system wide. Apparently it doesn’t work when putting it to Session and Startup/Application Autostart in XFCE too.
How can I achieve this?

It works, when I make my own “launch script” for each app on chromium which checks the gpu and then launches the app with the VK_DRIVER_FILES= or without, but that seems not very elegnat to me.

Thanks for the answers.

You may want to have a look at the wiki: https://wiki.archlinux.org/title/Environment_variables#Globally

nano /etc/environment
nano /etc/profile
nano .bashrc

You can apply variables globally or per user if the device has multiple users.

So if I get it right, the script will look like this?

#!/bin/bash

string=$(glxinfo | grep 'Vendor')

if [[ "$string" =~ .+Intel.+ ]]; then
    echo "True"
    echo "VK_DRIVER_FILES= " >> /etc/profile
else
    echo "False"
fi

Is the variable going to be wiped out on log out, or does it stay in the /etc/profile?

It doesn’t look like it will. You’ll have to check it.

Finally solved it by myself:

STEP1:

Create ~/.xinitrc and ~/.xprofile files as described here:
https://wiki.archlinux.org/title/Xprofile
and paste this code inside the ~/.xinitrc :

#!/bin/sh

# Make sure this is before the 'exec' command or it won't be sourced.
[ -f /etc/xprofile ] && . /etc/xprofile
[ -f ~/.xprofile ] && . ~/.xprofile

STEP2:

Paste this code inside the /.xprofile :

string=$(inxi -G | grep 'NVIDIA')

if [[ "$string" =~ .+NVIDIA.+ ]]; then
    echo "True"
else
    echo "False"
    export VK_DRIVER_FILES= 
fi

It checks if a Nvidia GPU is present in your device and sets the VK_DRIVER_FILES= environment variable accordingly.

This solves the issue with slow launch of chromium based apps, when running Endeavour OS on a device without Nvidia GPU.

3 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.