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:
export QT_STYLE_OVERRIDE=GTK+
[ -f ~/.xprofile ] && source ~/.xprofile
~/.screenlayout/default.sh
awesome
And my ~/.xprofile
like this:
[[ -f ~/.bashrc ]] && . ~/.bashrc
source /etc/bash_completion.d/virtualenvwrapper
export GDK_NATIVE_WINDOWS=1
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?
Best Answer
~/.xinitrc
is only read when you start a GUI session withstartx
(or otherwise callingxinit
) 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
(callposix.setenv("QT_STYLE_OVERRIDE", "GTK+")
to set an environment variable).