This forum has been archived. All content is frozen. Please use KDE Discuss instead.

make path environment set in .bashrc available in krunner

Tags: None
(comma "," separated)
StMartin81
Registered Member
Posts
26
Karma
0
Hello,

I have a script which gets called by .bashrc and sets some variables. Among other things the script modifies the path variable. Does anybody now how make these environment variables available to krunner? Adding the cripts file to "System Settings" -> "Autostart" -> "Script File" doesn't work for me.


Regards
Martin
User avatar
google01103
Manager
Posts
6668
Karma
25
do you export the variables?

have you tried placing the variables in ~/.bash_profile

update - so I looked at mine and I don't export $PATH (though I do the variables I set) and Krunner finds executables that are in my PATH.

If you echo $PATH in Konsole does your path show correctly? do your variables?


OpenSuse Leap 42.1 x64, Plasma 5.x

StMartin81
Registered Member
Posts
26
Karma
0
I got it working. I've created a .xprofile file in my home directory as neither .bash_profile nor .bashrc get called by kdm.

The .xprofile file calls .bash_profile which in turn calls .bashrc.

One thing I like to know though is why .xprofile gets called two times during login? Also the PATH environment variable gets reset between the two calls. Can anybody tell me where the places are where the PATH environmnent gets set during the login?
User avatar
google01103
Manager
Posts
6668
Karma
25
this sounds wrong to me, if you login a virtual terminal (Alt+Ctrl+F1) is your bashrc called? because obviously xprofile won't have called it


OpenSuse Leap 42.1 x64, Plasma 5.x

StMartin81
Registered Member
Posts
26
Karma
0
Ah, I was wrong only .bashrc and .bash_profile get called two times after login. But I still don't understand why these two files are called two times. At least there is no terminal open and I don't see a bash process.
User avatar
google01103
Manager
Posts
6668
Karma
25
you never said if those variables were showing in Konsole before you added them to .xprofile


OpenSuse Leap 42.1 x64, Plasma 5.x

StMartin81
Registered Member
Posts
26
Karma
0
Hello

I dont's understand your last replay.

When I open konsole .bashrc and .bashprofile get executed. When I login to KDE .xprofile get executed one time, which in turn will call .bashprofile which will call .bashrc. Then .bash_profile gets called a second time.

So the sequence looks like this (at least I assume this is what's happening):
Time 1: .xprofile -> .bash_profile -> .bashrc (set PATH variable)
Time 2: PATH variable gets reset
Time 3: .bash_profile -> .bashrc (set PATH varialbe again)

Hope this clarifies things.
User avatar
google01103
Manager
Posts
6668
Karma
25
what I don't understand is why your system is not executing .bash_profile at login which is how I understand it is supposed to happen.


OpenSuse Leap 42.1 x64, Plasma 5.x

StMartin81
Registered Member
Posts
26
Karma
0
You are right: .bash_profile gets executed without .xprofile.

The reason why I was calling .bash_profile from .xprofile was that the "Application Launcher" didn't seem to recognize the changed PATH variable and I thought that when I set the PATH variable earlier it would see the new PATH environment.

I've removed the .xprofile file now and .bash_profile gets called. Somehow the "Application Launcher" now also sees the changed PATH variable.

Thanks a lot for pointing me to the right direction! I have no idea what the problem was, or if there ever was a problem in the first place. At least it works as expected now. :-)
User avatar
google01103
Manager
Posts
6668
Karma
25
I was just confused because Krunner sees my PATH no problem

glad it's fixed, please mark thread solved


OpenSuse Leap 42.1 x64, Plasma 5.x

User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
I will also note that KDE allows you to have an "env" folder in your localprefix, containing shell scripts which set up environment variables. These scripts must be executable.

Your localprefix can be found by executing:
Code: Select all
kde4-config --localprefix


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
google01103
Manager
Posts
6668
Karma
25
bcooksley wrote:I will also note that KDE allows you to have an "env" folder in your localprefix, containing shell scripts which set up environment variables. These scripts must be executable.

Your localprefix can be found by executing:
Code: Select all
kde4-config --localprefix


there is a kcm module for facilitating this for scripts located not in the ~/.kde[4]/env fordler: systemsettings -> startup and shutdown -> autostart -> script files -> add script (as symbolic link) -> pre-KDE startup

some people call thier env file myenv.sh


OpenSuse Leap 42.1 x64, Plasma 5.x

StMartin81
Registered Member
Posts
26
Karma
0
I wanted to set the environment variables in .bashrc because they are not KDE specific and setting them in this place makes them available for other DEs also.
FVue
Registered Member
Posts
1
Karma
0
I think you shouldn't set/export environment variables in .bashrc but in .profile instead, because this is the file that definitely gets included by the display manager (e.g. lightdm) - which boots your graphical environment - no matter what is your login-shell setting. See: /usr/sbin/lightdm-session (shell script, Ubuntu-12.04).

If you have a ~/.bash_profile, make sure to include .profile from there:
Code: Select all
[[ -f ~/.profile ]] && . ~/.profile
This will set your environment variables via .profile if you login via a text terminal (and your login-shell is set to bash).

If you run a program within the graphical environment via ALT-F2 (KRunner), no new shell is started, so .bashrc will not be included at that time either. Only the exports you did in ~/.profile will be active. You can do the code underneath to see KRunner's environment variables:
Code: Select all
cat /proc/$(pidof krunner)/environ | tr '\000' '\012'
Kubunt-12.04 uses kdm which still includes .bash_profile (see: /etc/kde4/kdm/Xsession), but starting from Kubuntu-12.10, lightdm is used as well?

I pursued this problem while trying to set the BROWSER environment variable. See: http://fvue.nl/wiki/Linux:_Default_browser
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Note that if you are concerned that ~/.bashrc or ~/.profile are being ignored, a executable *.sh file under ~/.kde4/env/ will always be included by startkde as part of the KDE startup process. Note that ~/.kde4/ may not be correct for your distribution (in which case use ~/.kde/) and that you may need to create the 'env' folder yourself.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: abc72656, Bing [Bot], daret, Google [Bot], lockheed, Sogou [Bot], Yahoo [Bot]