2

I have actually one environment variable that is needed by some GUI applications : QT_QPA_PLATFORMTHEME=qt5ct. For now I export it in ~/.bashrc.

When I run qt5ct from a terminal, the app sees the environment variable. But not when it is run from a desktop file.

So I tried multiple ways, changing the Exec= line of the desktop file (launching qt5ct show me if the app sees the environment variable):

  • sh -e 'qt5ct' : not detecting
  • sh -c 'qt5ct' : not detecting
  • sh -a -e 'qt5ct' : not detecting
  • bash -c 'qt5ct' : not detecting

Finally, managed to find a tricky way (in my opinion) that works:

  • /usr/bin/env QT_QPA_PLATFORMTHEME=qt5ct qt5ct : detecting

So my question is : is there any way to export the variable environment QT_QPA_PLATFORMTHEME such as I do in ~/.bashrc ? Since it takes me time to edit manually desktop entries (and perhaps these will be overwritten automatically by an update of the app ?).

I tried an export in ~/.bashrc, ~/.profile, without any change, and I don't have any ~/.xsession.

P.S. Sorry if there are English mistakes, and also if the title is not as accurate as my question.

  • When you put it in .profile, did you log out and back in? ~/.profile for the desktop environment is loaded during login only. – FelixJN Jan 13 '22 at 22:14
  • Yes, I even rebooted to be sure. The exported environment variable - in ~/.profile - is still not detected by the app (from desktop file). – TheBigBadBoy Jan 13 '22 at 22:31
  • 2
    Persistent system-wide variables should be put in /etc/environment (no export here). Did you try this yet? – FelixJN Jan 13 '22 at 22:43
  • Works ! In /etc/environment the variable is correctly detected ! Thanks again for your time. Perhaps you want to publish it as an answer, to gain points ? If no, there is no problem and I can answer this thread to mark it as resolved. – TheBigBadBoy Jan 13 '22 at 23:14

1 Answers1

2

System-wide variables my be set in /etc/environment. Please be aware that this file does not take variables or shell code but is meant for static variables only, written as:

QT_QPA_PLATFORMTHEME=qt5ct

Usually ~.profile should be sources for GUI-logins, but it seems that there is a certain argument between maintainers regarding this. See this thread - the general idea behind not sourcing ~/.profile being that originally the file was meant for shell logins and a GUI login is not considered a shell login. So the file not being sourced might be related to your current desktop manager.

FelixJN
  • 13,566