Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Solved] XFCE not reading profile files

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
User avatar
PsySc0rpi0n
Posts: 322
Joined: 2012-10-24 13:54
Location: Bitcoin World
Has thanked: 8 times
Been thanked: 1 time

[Solved] XFCE not reading profile files

#1 Post by PsySc0rpi0n »

Hello.

I'm using Debian Buster with Xfce 4.12.

I have installed and I've been using Xfce but I can't make files ,such as ~/.profile, ~/.bash_profile and others like that, to be read by bash when my system boots up.
So, every time I open a terminal window, I need to manually run `source ~/.profile`so that the paths I want to add to $PATH becomes available for that terminal.

What am I missing here?
Last edited by PsySc0rpi0n on 2021-02-06 18:47, edited 1 time in total.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: XFCE not reading profile files

#2 Post by Head_on_a_Stick »

deadbang

User avatar
PsySc0rpi0n
Posts: 322
Joined: 2012-10-24 13:54
Location: Bitcoin World
Has thanked: 8 times
Been thanked: 1 time

Re: XFCE not reading profile files

#3 Post by PsySc0rpi0n »

They say there to use the file .xsessionsrc. But I can't even find this file in my system.

Not sure why but I couldn't find it. Is it supposed that I have it in the first place or I have to create it in my $HOME ?

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: XFCE not reading profile files

#4 Post by Head_on_a_Stick »

PsySc0rpi0n wrote:I have to create it in my $HOME
^ This.

See also https://wiki.debian.org/Xsession

Search engines are quicker than waiting for a reply on forums.
deadbang

pendrachken
Posts: 1394
Joined: 2007-03-04 21:10
Location: U.S.A. - WI.

Re: XFCE not reading profile files

#5 Post by pendrachken »

PsySc0rpi0n wrote:Hello.

I'm using Debian Buster with Xfce 4.12.

I have installed and I've been using Xfce but I can't make files ,such as ~/.profile, ~/.bash_profile and others like that, to be read by bash when my system boots up.
So, every time I open a terminal window, I need to manually run `source ~/.profile`so that the paths I want to add to $PATH becomes available for that terminal.

What am I missing here?

You are missing the fact that you don't want / need X / your DE messing with your $PATH. You want bash to have the $PATH every time you open the terminal.

You need to put the PATH you want in ~/.bashrc, as Debian has that file sourced by default for both interactive, login, and non-login shells. That should cover having the updated $PATH no matter what kind of stupid crap your terminal emulator is doing.

See: https://unix.stackexchange.com/question ... consistent
fortune -o
Your love life will be... interesting.
:twisted: How did it know?

The U.S. uses the metric system too, we have tenths, hundredths and thousandths of inches :-P

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: XFCE not reading profile files

#6 Post by Head_on_a_Stick »

pendrachken wrote:You need to put the PATH you want in ~/.bashrc
Environmental variables shouldn't be added to ~/.bashrc because that file only applies to bash itself. The OP might want to export their custom PATH for other programs and that wouldn't work with your suggestion.

See also https://superuser.com/questions/183870/ ... 980#183980
deadbang

User avatar
PsySc0rpi0n
Posts: 322
Joined: 2012-10-24 13:54
Location: Bitcoin World
Has thanked: 8 times
Been thanked: 1 time

Re: XFCE not reading profile files

#7 Post by PsySc0rpi0n »

I created this ~/.xsessionrc and placed inside:

Code: Select all

source ~/.profile
bu this is not working. After logging out an back in or even after restarting, it still can't see the paths I wanted to add to $PATH.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: XFCE not reading profile files

#8 Post by Head_on_a_Stick »

That's a bashism and I think ~/.xsessionrc is read by /bin/sh (hence dash).

Try

Code: Select all

. ~/.profile
EDIT: or use this in ~/.xsessionrc to avoid creating extraneous PATH entries:

Code: Select all

case "$PATH" in
   */added/directory*) ;;
   *) PATH=/added/directory:"$PATH"
esac
export PATH
Replace "/added/directory" with the actual directories that you want to add to PATH.
deadbang

User avatar
PsySc0rpi0n
Posts: 322
Joined: 2012-10-24 13:54
Location: Bitcoin World
Has thanked: 8 times
Been thanked: 1 time

Re: XFCE not reading profile files

#9 Post by PsySc0rpi0n »

Head_on_a_Stick wrote:That's a bashism and I think ~/.xsessionrc is read by /bin/sh (hence dash).

Try

Code: Select all

. ~/.profile
EDIT: or use this in ~/.xsessionrc to avoid creating extraneous PATH entries:

Code: Select all

case "$PATH" in
   */added/directory*) ;;
   *) PATH=/added/directory:"$PATH"
esac
export PATH
Replace "/added/directory" with the actual directories that you want to add to PATH.
Ok, that worked... I chose to use the latter one.
So, if I want to add more folders, do I need to create another block like that or I can use that block to add other folders?



edited;

For instance, if I need to add

Code: Select all

~/Downloads/my-program
and

Code: Select all

~/Downloads/your-program
can it be done like this:

Code: Select all

[code]case "$PATH" in
   *~/Downloads/my-program*) ;;
   *) ~/Downloads/my-program:"$PATH"
 
   *~/Downloads/your-program*) ;;
   *) ~/Downloads/your-program:"$PATH"
esac
export PATH
[/code]
Last edited by PsySc0rpi0n on 2021-02-06 18:17, edited 1 time in total.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: XFCE not reading profile files

#10 Post by Head_on_a_Stick »

You can add all the directories you want in the same case statement, for example:

Code: Select all

dirs=/first/directory:/second/directory:/third/directory
case "$PATH" in
   *"$dirs"*) ;;
   *) PATH="$dirs":"$PATH"
esac
export PATH
deadbang

User avatar
PsySc0rpi0n
Posts: 322
Joined: 2012-10-24 13:54
Location: Bitcoin World
Has thanked: 8 times
Been thanked: 1 time

Re: XFCE not reading profile files

#11 Post by PsySc0rpi0n »

Head_on_a_Stick wrote:You can add all the directories you want in the same case statement, for example:

Code: Select all

dirs=/first/directory:/second/directory:/third/directory
case "$PATH" in
   *"$dirs"*) ;;
   *) PATH="$dirs":"$PATH"
esac
export PATH

Ahh ok. I see. Thanks. Will try and report back

User avatar
PsySc0rpi0n
Posts: 322
Joined: 2012-10-24 13:54
Location: Bitcoin World
Has thanked: 8 times
Been thanked: 1 time

Re: XFCE not reading profile files

#12 Post by PsySc0rpi0n »

Ok, with the last suggestion, it didn't work, I mean, with the multiple dirs...

This is my ~/.xsessionrc file:

Code: Select all

$ cat .xsessionrc 
incdirs=~/Downloads/bitcoin-0.21/src:~/Downloads/lightning/cli:~/Downloads/lightning/lightningd:~/Downloads/mcabber/mcabber/mcabber:~/Storage/Software/Linux/openocd/src:~/Storage/Software/Linux/gcc-arm-none-eabi-10-2020-q4-major/bin

case "$PATH" in
   *"$dirs"*) ;;
   *) PATH="$dirs":"$PATH"
esac
export PATH

Edited;
Stupid me... Forget it...
Last edited by PsySc0rpi0n on 2021-02-06 18:32, edited 1 time in total.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: XFCE not reading profile files

#13 Post by Head_on_a_Stick »

That's because you've declared an "incdirs" variable in the first line but used the "dirs" variable in the case statement. Both variable names have to match.
deadbang

User avatar
PsySc0rpi0n
Posts: 322
Joined: 2012-10-24 13:54
Location: Bitcoin World
Has thanked: 8 times
Been thanked: 1 time

Re: XFCE not reading profile files

#14 Post by PsySc0rpi0n »

Thanks. Stupid me...

I think this one is solved.
Thanks everyone.

Post Reply