Re: kde programs and environment
> How do I forward environment variables to kde program?
> I am using ktexmaker2 and it does not see my TEXINPUTS
> environment variable when I click a TeX file. When I start
> ktexmaker2 from a shell it is fine but then I have to use the
> open button to get to the file. Direct clicking is more convenient.
>
> Any ideas?
You seem to be one more person hit by this problem...
The traditional way to set up user's environment is the login shell startup
script (~/.bash_login for bash). You set environment variables there and
export them, and later all processes you start have the correct environment.
The problem is that in the current setup, when you login via XDM (or KDM),
you have no login shell and no way to set up local environment.
KDM executes /etc/kde2/kdm/Xsession - a normat shell script, it is run by
non-login shell, and as long as shell process that executes it is not
interactive, it does not read ~/.bashrc.
/etc/kde2/kdm/Xsessions starts /etc/X11/Xsession. Same story.
/etc/X11/Xsession starts your desktop. So the desktop processes are started
without environment set.
When you later start applications from menu (or Alt+F2), they are also
started without environment set.
But if you start xterm (or konsole or other X shell), bash started there is
interactive and sources .bashrc. So if environment variables are set in
.bashrc, you will see tham set in xterm window. And processes start from
there will get them set.
This may become really confusing for a user.
And it is wrong thing to do. Non-login interactive shell startup script
(.bashrc) is NOT the correct place to set up environment, because (as
explained above) it will make the environment inconsistent - one processes
wil get it set, others won't. And because this makes hard to work with
local environment changes. E.g. you change a var (e.g. $PATH), then start
mc and not see your change there.
Environment should be set ONCE PER SESSION in such place that ALL session
process may see it.
For system-wide environment, there is /etc/environment that is read by
pam_env. Vars set in /etc/environment will be visible to ALL user's
processes, regardless of login method (text console or xdm/kdm or ssh).
Seems that currently there is NO WAY to set up user's own environment
corectly (unless pam_env can read some per-user configuration which I am
not aware of).
A possible workaround is to make /etc/kde2/kdm/Xsession run by login shell,
and set up your environment to ~/.bash_login. This will end to consistent
environment. To do so, edit /etc/kde2/kdm/Xsession and replace
#!/bin/sh
by
#!/bin/bash --login
Note that doing so in /etc/X11/Xsession is not correct, because this script
may be also run when X is started from command line, when environment is
also set and possibly modified by user for the current session.
Note also that if your shell is not bash, you will have to duplicate
settings in ~/.bash_login and in your shell's login startup script.
That's why a better solution it to use per-user files loaded by pam_env.
But I don't know if they are supported.
Reply to: