[Solved] XFCE not reading profile files

If none of the more specific forums is the right place to ask

[Solved] XFCE not reading profile files

Postby PsySc0rpi0n » 2021-01-30 23:58

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
PsySc0rpi0n
 
Posts: 247
Joined: 2012-10-24 13:54
Location: Portugal

Re: XFCE not reading profile files

Postby Head_on_a_Stick » 2021-01-31 08:33

Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 13280
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: XFCE not reading profile files

Postby PsySc0rpi0n » 2021-01-31 10:29

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
PsySc0rpi0n
 
Posts: 247
Joined: 2012-10-24 13:54
Location: Portugal

Re: XFCE not reading profile files

Postby Head_on_a_Stick » 2021-01-31 10:31

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.
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 13280
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: XFCE not reading profile files

Postby pendrachken » 2021-02-06 14:31

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
pendrachken
 
Posts: 1386
Joined: 2007-03-04 21:10
Location: U.S.A. - WI.

Re: XFCE not reading profile files

Postby Head_on_a_Stick » 2021-02-06 15:17

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
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 13280
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: XFCE not reading profile files

Postby PsySc0rpi0n » 2021-02-06 16:37

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
PsySc0rpi0n
 
Posts: 247
Joined: 2012-10-24 13:54
Location: Portugal

Re: XFCE not reading profile files

Postby Head_on_a_Stick » 2021-02-06 16:41

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.
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 13280
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: XFCE not reading profile files

Postby PsySc0rpi0n » 2021-02-06 18:08

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
PsySc0rpi0n
 
Posts: 247
Joined: 2012-10-24 13:54
Location: Portugal

Re: XFCE not reading profile files

Postby Head_on_a_Stick » 2021-02-06 18:16

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
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 13280
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: XFCE not reading profile files

Postby PsySc0rpi0n » 2021-02-06 18:17

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: 247
Joined: 2012-10-24 13:54
Location: Portugal

Re: XFCE not reading profile files

Postby PsySc0rpi0n » 2021-02-06 18:27

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
PsySc0rpi0n
 
Posts: 247
Joined: 2012-10-24 13:54
Location: Portugal

Re: XFCE not reading profile files

Postby Head_on_a_Stick » 2021-02-06 18:30

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.
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 13280
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: XFCE not reading profile files

Postby PsySc0rpi0n » 2021-02-06 18:47

Thanks. Stupid me...

I think this one is solved.
Thanks everyone.
User avatar
PsySc0rpi0n
 
Posts: 247
Joined: 2012-10-24 13:54
Location: Portugal


Return to General Questions

Who is online

Users browsing this forum: No registered users and 13 guests

fashionable