You are not logged in.

#1 2017-10-30 04:27:36

Anexthesy
Member
Registered: 2017-03-17
Posts: 9

[SOLVED] i3wm overrides $PATH

Hi,

I just switched from xfce4 to i3wm and now I have the following issue: whenever I set my PATH variable in ~/.xprofile (xprofile is called, already verified), it is overriden (somehow) by i3wm.

This didn't happen with xfce4 ; I could call scripts from my PATH in bash or with keybinds, now it just doesn't work either way.

Any idea why this is happening?

Last edited by Anexthesy (2017-10-30 16:33:22)

Offline

#2 2017-10-30 04:56:54

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOLVED] i3wm overrides $PATH

You set your PATH in your shell initialisation files: .bash_profile, .profile or .zprofile.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2017-10-30 12:00:52

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,530
Website

Re: [SOLVED] i3wm overrides $PATH

Anexthesy wrote:

xprofile is called

By what?  When?

Anexthesy wrote:

... it is overriden (somehow) by i3wm.

How do you know this?

Post symptoms, not your interpretations.  Note too that environment variables are for an environment; they are not global.  If "xprofile is called" from a process that is not a parent process to i3wm, then you should not expect i3wm to inherit those settings.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#4 2017-10-30 13:25:45

Anexthesy
Member
Registered: 2017-03-17
Posts: 9

Re: [SOLVED] i3wm overrides $PATH

I already tried sourcing xprofile from .bash_profile, I will try the others just in case.

xprofile is called at the initilalization of LightDM. I verified it was called by creating a file from xprofile. It did create it.

I think you might be right, when I launch xfce4-terminal, it is from i3wm and when I echo $PATH, I find none of my paths, so maybe i3wm simply doesn't inherit PATH from xprofile.
I assumed (sorry) it was overriden, because xfce4 actually shared the PATH variable with LightDM. Is there a way to source xprofile for i3wm?

EDIT: clarifications

Last edited by Anexthesy (2017-10-30 13:31:25)

Offline

#5 2017-10-30 13:31:00

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,530
Website

Re: [SOLVED] i3wm overrides $PATH

You could source xprofile, but this is really not the best way of setting your PATH variable.

To know what will work we need to know how you start X and i3wm.  You listed some of the players in your previous post, but I can't really make sense of it.  You use lightDM to log in, right?  Then you list i3wm as starting xfce4, that doesn't make sense.  Does lightDM start xfce which in turn uses i3wm as the WM in place of xfwm?


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2017-10-30 13:32:44

Anexthesy
Member
Registered: 2017-03-17
Posts: 9

Re: [SOLVED] i3wm overrides $PATH

I am so sorry, I made a typo, i3wm launches xfce4-terminal, not xfce4. LightDM previously started xfce4, but now I only use i3wm.

Offline

#7 2017-10-30 13:39:03

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,530
Website

Re: [SOLVED] i3wm overrides $PATH

Then anything that sets the environment within (or above) lightDM should work - but I have no experience with lightDM and next to no experience with DMs at all.  Do you need a DM?  If not you may want to consider ditching it.  DMs serve little purpose other than to break things and make simple things like what you are trying to do difficult.

The lightDM wiki page has the following options for setting environment variables:
https://wiki.archlinux.org/index.php/Li … _displayed

That is about setting LANG, but setting PATH could be done similarly.  As to whether this is the best approach, I have no idea.

Another approach is just to use the full path to executables outside of /usr/bin in your i3wm bindings.  This would certainly be the cleanest approach.

Last edited by Trilby (2017-10-30 15:18:48)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#8 2017-10-30 15:15:15

seth
Member
Registered: 2012-09-03
Posts: 51,221

Re: [SOLVED] i3wm overrides $PATH

sourcing the relevant export in lightdm is probably useless - you got the $PATH in lightdm, but lightdm probably runs as root and should *certainly* drop its environment before starting a session to not bleed into that.
If ~/.xprofile isn't sourced by your i3wm session startup, it's not sourced in your session.

Online

#9 2017-10-30 15:22:09

Anexthesy
Member
Registered: 2017-03-17
Posts: 9

Re: [SOLVED] i3wm overrides $PATH

I do not need a DM now that you mention it. I will try a DMless approach, if it doesn't work I will edit /etc/environment.

I use PATH for Android SDK and scripts. I agree it is not the cleanest or the most secure way to do things, but it works fine with my current workflow.

Offline

#10 2017-10-30 15:31:13

seth
Member
Registered: 2012-09-03
Posts: 51,221

Re: [SOLVED] i3wm overrides $PATH

Do NOT write user specific environments into /etc/environment. Figure what your session sources and add it there (although with xinit, this won't be a problem)

Online

#11 2017-10-30 16:24:35

Anexthesy
Member
Registered: 2017-03-17
Posts: 9

Re: [SOLVED] i3wm overrides $PATH

So I completely removed LightDM, now I'm using bashrc to start X11.
I sourced .xprofile in my .xinitrc and now the PATH is replaced with the new one. i3wm still doesn't detect scripts inside my new PATH, but it's not critical.
As long as Android Studio locates the SDK correctly, I'm fine with it. I will go with absolute paths inside i3 config for my scripts.

Thanks a lot guys! You've been really helpful smile

PS: How do I mark this as solved?

Offline

#12 2017-10-30 16:29:00

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,791

Re: [SOLVED] i3wm overrides $PATH

Anexthesy wrote:

PS: How do I mark this as solved?

Edit your first post in the tread.  There is an option (on the first post only) to change the thread title. Just prepend [SOLVED]


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#13 2017-10-30 16:59:56

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOLVED] i3wm overrides $PATH

And what happens when you want that extended path in the console?


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB