0

I can't figure out how to set environment variables properly, even though I tried to follow https://wiki.debian.org/EnvironmentVariables.

I've added this to ~/.bashrc:

if [ -f ~/.bash_profile ]; then
    . ~/.bash_profile
fi

It seemed logical to me to comment these lines in ~/.profile after doing that:

# if running bash
# if [ -n "$BASH_VERSION" ]; then
#    # include .bashrc if it exists
#    if [ -f "$HOME/.bashrc" ]; then
#   . "$HOME/.bashrc"
#    fi
#fi

Now when I open a terminal, variables in ~/.profile and ~/.bash_profile are correctly exported.

How do I make the variables in ~/.profile available for applications I launch through XFCE menu? I know it isn't the case because if I launch gpodder from a terminal, it does what I want, ie. it detects $GPODDER_HOME which is set in my .profile, but this doesn't happen when I launch it "graphically".

  • Your display manager doesn't source .profile at startup? You could use /etc/environment (and ~/.pam_environment) for variables other than PATH. – muru Apr 17 '16 at 14:43
  • ~/.pam_environment didn't help. :( Isn't it 'dirty' to modify /etc/environment for my podcast download folder? – nicoco Apr 17 '16 at 14:50
1

See man xsession:

/etc/X11/Xsession.d/40x11-common_xsessionrc

Source global environment variables. This script will source anything in $HOME/.xsessionrc if the file is present. This allows the user to set global environment variables for their X session, such as locale information.

  • This looks better than what I did. I'll test it later and approve your answer if it works. – nicoco Apr 19 '16 at 11:27
  • . /home/nicoco/.profile in . /home/nicoco/.xsessionrc was what I was looking for! – nicoco May 12 '16 at 17:53
0

I finally added a profile.desktop file in ~/.config/autostart that looks like this:

~/.config/autostart$ cat profile.desktop 
[Desktop Entry]
Encoding=UTF-8
Version=0.9.4
Type=Application
Name=profile
Comment=
Exec=/bin/bash /home/nicoco/.profile
OnlyShowIn=XFCE;
StartupNotify=false
Terminal=false
Hidden=false

This is the only workaround I found that doesn't involve modifying files as root.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.