14

Have recently installing Debian Wheezy and using XFCE 4.8.0.3 with lighdm.

After logging in with lightdm, my ~/.bash_profile or ~/.profile are no longer sourced. I have previously used these startup files to start ssh-agent, dropboxd and set my PATH variable.

If I understand this link (http://wiki.debian.org/DotFiles) correctly, when a display manager is in use (lightdm in this case). Then it is correct that these files do not get sourced.

So my questions are:
1) how can I make XFCE/lightdm source ~/.bash_profile or ~/.profile
or
2) what are the equivalent startup configuration files of XFCE/lightdm to start ssh-agent, dropboxd and set my PATH variable.

Mikel
  • 8,846
  • 1
  • 41
  • 37
James P
  • 393
  • 1
  • 4
  • 12

2 Answers2

10

I've also struggled a lot with this environment variable thing. I'm using Debian Jessie + xfce4

The options that worked for me are(for the environment variables to be caught by the desktop manager):

  • With xdm or lightdm: use ~/.xsessionrc
  • With others, I haven't tested

In the ~/.xsessionrc you may chose to :

  • put directly the variables, like PATH="$PATH:userpath"
  • or source the ~/.profile file: . $HOME/.profile, where the ~/.profile file contains the environment variables definitions

Note the dot in the second option which means source, but I think source is bash specific. The second method is probably recommended (as argued in https://unix.stackexchange.com/questions/4621/correctly-setting-environment) and avoid having the environment variables defined in several files. Also, it's user-specific and not system-wide like (/etc/environment, which actually didn't work so well for me)

For terminal session, since I use bash, I set-up the environment variables in the .bash_profile or I just source the ~/.profile

e-malito
  • 291
  • 3
  • 6
  • Thanks alot ! Finally! I had to search alot to find this easy solution. One thing to mention: If the file ~/.xsessionrc does not exist, just create it ! – Alex Aug 22 '14 at 15:09
  • 1
    At first in `~/.xsessionrc` I put `. ~/.profile` and it did not work. As stated in this answer if the content is `. $HOME/.profile` then it works. – Stéphane Gourichon Mar 17 '16 at 19:57
  • What I find to be **important**: `~/.xsessionrc` is executed by plain `/bin/sh`, so the script needs to be POSIX compliant. See an [example here](https://unix.stackexchange.com/a/708372/22339). – Petr Jul 02 '22 at 14:09
3

OK eventually found a workable solution and went with 2)

To set my PATH variable.
$ cp /etc/xdg/xfce4/xinitrc ~/.config/xfce4
Then edited ~/.config/xfce4/xinitrc to include the following near the top of the file

if [ -d "${HOME}/bin" ] ; then
    PATH="${HOME}/bin:${PATH}"
fi

To start Dropbox when XFCE4 starts
$ xfce4-settings-manager
-> Session and Startup -> "Application Autostart" tab -> Add ->
Name: Dropbox
Command: /home/james/.dropbox-dist/dropboxd
-> OK

As for ssh-agent this gets started in the default xinitrc. (Can anyone recommend a GUI program to supply the passphrase)

Hope this is of assistance.

James P
  • 393
  • 1
  • 4
  • 12
  • 1
    Copying and editing a file from `/etc/` smells. If the packages updates the original file your copy won't be updated. An alternative would be to copy no content but `exec /etc/xdg/xfce4/xinitrc` from your `~/.config/xfce4/xinitrc`right after your specific setup. Anyway I prefer the other `.profile`-based solution, which seems less specific to xfce or lightdm. Thanks for sharing! – Stéphane Gourichon Mar 17 '16 at 20:33
  • GUI program to supply the passphrase: ssh-askpass-gnome, ssh-askpass, ssh-askpass-fullscreen. Also recommend GNU Keychain for keychain management. – fatal_error Dec 06 '16 at 22:21