Environment variables in X Applications


Im using KDE and the default I think its SDDM and XOrg since I have Nvidia Wayland won’t work as it is now.
I have googled and checked https://wiki.archlinux.org/title/environment_variables to see what files to use to set environment variables for X Applications like Visual Studio Code, Intellij and so on…

The problem is Im using a Yubikey for SSH public key authentication and I have placed my public ssh key in a Git repository to use for checkouts and with a few environment variables I get a prompt (pinentry-program /usr/bin/pinentry-qt) for a pin when I want to check out or login to ssh.
I need environment variables like “SSH_AUTH_SOCK” to be set for this to work.

According to the Arch Wiki I should use ~/.xprofile or ~/.zprofile but this doesnt work!

If I have the needed environment variables in ~/.xprofile and manually edit the startup script for intellij for example and add

source "$HOME/.xprofile"

Then it works pefectly in intellij, but do I really need to do this for each application I need this??
Should I use a different file for these environment settings?

Im using zsh as a shell but the intellij script uses bash as far as I can see (most scripts do I suppose?)…

Can anyone help?

/etc/environment is a good place, there is something KDE specific:


You need to make sure your environment variables are set appropriately, for the shell you use.
For zsh, use zsh startup/shutdown files (Tip: ~/.zshenv)
Or change shell to bash, which, as you say, it works. :man_shrugging:

What ssh has to do with X (.xprofile)? You may have misinterpreted.
Archwiki talks about your shell startup files. Where did you read about .xprofile ?

Sddm should work with .profile

You cqn use environment.d in .config but then you have to add a systemd generator command that use environment.d



Thanks, ~/.zshenv worked as I needed!
I read about ~/.xprofile in https://wiki.archlinux.org/title/environment_variables#Per_Xorg_session

1 Like

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