My setup is:

  • Debian testing (stretch), up to date
  • LightDM with autologin enabled
  • Awesome window manager
  • bash, in ROXTerm or XTerm

I don't seem to be able to set own environment variables and get it sourced at X session startup. Here's what I tried:

  • using ~/.bash_profile worked on my previous OS, but I learned from this answer that it isn't sourced on X startup in Debian and it's derivatives
  • I did mv .bash_profile .profile as suggested, but it didn't work too because, as I learned later from here, ~/.profile isn't sourced when display manager launches X session
  • the answer from above question suggests use of ~/.xsessionrc. This also didn't work because, as I learned from here, it is sourced only by /etc/X11/Xsession which LightDM doesn't execute
  • Arch Linux wiki claims that LightDM sources ~/.xprofile files, but that didn't work too.

Trying advice from that last site, I made my ~/.xinitrc like this:

[ -f ~/.xprofile ] && source ~/.xprofile

And my ~/.xprofile like this:

[[ -f ~/.bashrc ]] && . ~/.bashrc
source /etc/bash_completion.d/virtualenvwrapper

export WORKON_HOME=$HOME/env/

Sadly, after logging in and starting X session, I see that none of these variables are set:

red@localhost:~$ echo $QT_STYLE_OVERRIDE

red@localhost:~$ echo $GDK_NATIVE_WINDOWS

red@localhost:~$ echo $WORKON_HOME

How do I set them up properly?

  • Note that many graphical login managers do actually source ~/.profile. GDM, for example. Sadly, you're quite right that not all of them do. That said, the first thing you should try is adding something like touch /tmp/xprofile to your ~/.xprofile and touch /tmp/xinitrc to your ~/.xinitrc etc, so you can figure out which files are actually read.
    – terdon
    Apr 16, 2016 at 15:12
  • Actually, none of these has any effect. I also checked that awesome isn't run from ~/.xinitrc anymore, but configured with /usr/share/xsessions/awesome.desktop file that comes with package. This doesn't bring me any closer though. I also tried ~/.pam_environment which is supposed to work with LightDM, but no luck either.
    – Red
    Apr 16, 2016 at 17:23

1 Answer 1


~/.xinitrc is only read when you start a GUI session with startx (or otherwise calling xinit) after logging in in text mode. So that won't help you.

Whether ~/.bash_profile, ~/.profile, ~/.xprofile and ~/.xsessionrc are read when logging in with a display manager depends on how the display manager is configured and what session type you select when logging in. As far as I can tell, at least on Debian jessie (I haven't looked if this has changed since then):

  • /usr/share/lightdm/lightdm.conf.d/01_debian.conf tells Lightdm to use /etc/X11/Xsession as the session startup script.
  • /etc/X11/Xsession (via /etc/X11/Xsession.d/40x11-common_xsessionrc) loads $USERXSESSIONRC which is ~/.xsessionrc.

So ~/.xsessionrc should work, at least on Debian jessie.

On Debian, ~/.pam_environment should work to set environment variables for any login method.

Alternatively, you can set environment variables and run programs from Awesome via ~/.config/awesome/rc.lua (call posix.setenv("QT_STYLE_OVERRIDE", "GTK+") to set an environment variable).

  • This is still valid for debian buster / 10.2 . [the part with .xsessionrc]
    – u_Ltd.
    Nov 30, 2019 at 22:00
  • This does not work for LD_PRELOAD, LD_LIBRARY_PATH because ssh_agent is started. See man ssh_agent. TMPDIR is passed in /etc/X11/Xsession.d/90x11-common_ssh-agent , for the LD_* variables you have to amend 90x11-common_ssh-agent.
    – u_Ltd.
    Nov 30, 2019 at 22:03

You must log in to answer this question.

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