Xfce Forum

Sub domains
 

You are not logged in.

#1 2023-05-05 10:12:13

Jakob77
Member
Registered: 2022-11-03
Posts: 41

How to add a folder to PATH.?

In MX-Linux I want to add a folder to PATH and it works well in Terminal.

However I can't make Xfce understand it.

A command in a starter/launcher on the desktop or in the Panel can not work without entering full path.

So how do I add a folder to PATH in a way that can make it work in Xfce.?

Offline

#2 2023-05-05 10:39:36

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,198

Re: How to add a folder to PATH.?

Try creating a file in /etc/profile.d that adds to and exports the PATH variable:

PATH=$PATH:$HOME/mypath
export $PATH

During Xfce startup, it will process the file.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2023-05-05 11:23:17

Jakob77
Member
Registered: 2022-11-03
Posts: 41

Re: How to add a folder to PATH.?

ToZ wrote:

Try creating a file in /etc/profile.d that adds to and exports the PATH variable:

PATH=$PATH:$HOME/mypath
export $PATH

During Xfce startup, it will process the file.


Thank you.



I created a file:

/etc/profile.d/setpath.sh

containing only these two lines:

PATH=$PATH:$HOME/bin
export $PATH

After boot up I see no change in PATH

Did you forget to give me a proper filename or what did I do wrong.? :-)

Offline

#4 2023-05-05 13:41:14

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,198

Re: How to add a folder to PATH.?

What shell are you using? This location will only work for the Bourne shell and derivatives (sh, bash, ksh) if you are checking through your terminal.

However, it should work for Xfce as it uses Bourne as part of its startup files. Try adding a launcher to the panel that runs:

echo $PATH | zenity --text-info -

(put it inside of a script and add that script as a launcher).

When you launch it, it will display the PATH that Xfce is using.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#5 2023-05-05 14:52:56

Jakob77
Member
Registered: 2022-11-03
Posts: 41

Re: How to add a folder to PATH.?

I could not make the launcher work but if I use this line in Terminal:

echo $PATH | zenity --text-info -

this is how it looks:


$ echo $PATH | zenity --text-info -
Command 'zenity' not found, but can be installed with:
sudo apt install zenity

If I use full path in a Panel launcher to a script in ~/bin, and that script sends "echo @PATH >> PATH_logfile.txt" , I can read in that file that the PATH is amputated compared to the one configured in Terminal.

It looks like this:

/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

I believe the shell is Bash.

Last edited by Jakob77 (2023-05-05 15:00:25)

Offline

#6 2023-05-05 15:33:45

mint4all
Member
From: out of sight
Registered: 2018-08-21
Posts: 216

Re: How to add a folder to PATH.?

Greetings to y'all ...

A while back, I needed to prepend/append my system's global path. I accomplished this by editing (as root) the system-global /etc/environment file (note: Linux Mint -- YMMV).

Recently, I've begun to experiment with the RUST language. A found out that the installer added the ~/.cargo folder and its env script with the following content:

#!/bin/sh
# rustup shell setup
# affix colons on either side of $PATH to simplify matching
case ":${PATH}:" in
    *:"$HOME/.cargo/bin":*)
        ;;
    *)
        # Prepending path in case a system-installed rustc needs to be overridden
        export PATH="$HOME/.cargo/bin:$PATH"
        ;;
esac

Between my original tweak, and Rusts's installer, you may be able to figure out the specific workaround you want.

Cheers, m4a


Linux Mint 19.3, 20.3, 21.1 -- xfce 4.12 / 4.14 / 4.16 ... Apple iMAC -- Dell & HP Desktops -- Toshiba, Dell & HP Laptops -- Family & Community Support

Offline

#7 2023-05-05 16:14:14

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,198

Re: How to add a folder to PATH.?

Jakob77 wrote:

I could not make the launcher work but if I use this line in Terminal:

echo $PATH | zenity --text-info -

this is how it looks:


$ echo $PATH | zenity --text-info -
Command 'zenity' not found, but can be installed with:
sudo apt install zenity

Can you install zenity (its a small package) and try again?



I believe the shell is Bash.

echo $SHELL

I tested this in my MXLinux vm and it worked for me.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#8 2023-05-05 17:58:09

Jakob77
Member
Registered: 2022-11-03
Posts: 41

Re: How to add a folder to PATH.?

ToZ


When I try to install zenity I get this output:


$ sudo apt install zenity
Indlæser pakkelisterne... Færdig
Opbygger afhængighedstræ... Færdig
Læser tilstandsoplysninger... Færdig
Pakken zenity er ikke tilgængelig, men der refereres til den af en
anden pakke. Det kan betyde at pakken mangler, er blevet forældet
eller kun er tilgængelig fra en anden kilde

E: Pakken »zenity« har ingen installationskandidat

Not available, might be too old, has no installation candidate...



The other one works here also:

$ echo $SHELL
/bin/bash

It brings hope to the subject that you also have a MX distro. :-)

Offline

#9 2023-05-05 20:43:52

Jakob77
Member
Registered: 2022-11-03
Posts: 41

Re: How to add a folder to PATH.?

I got this suggestion from MX-forum:


Edit this file:

/etc/xdg/xfce4/xintrc

- at the top of that file, just under #!/bin/sh
add this :


# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

After reboot the users bin folder (if it exists) will be the first in PATH


Can you verify the solution as being compatible with Xfce.?

Offline

#10 2023-05-05 21:47:25

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,198

Re: How to add a folder to PATH.?

Possibly, but whenever the package that contains that file is updated, your changes will be lost (xfce4-session?).

The other option is to copy this file to ~/.config/xfce4/ and edit it there. This should override the one in /etc.

But strange that it didn't work in /etc/profile.d like it did for me.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#11 2023-05-06 07:23:01

Jakob77
Member
Registered: 2022-11-03
Posts: 41

Re: How to add a folder to PATH.?

ToZ wrote:

Possibly, but whenever the package that contains that file is updated, your changes will be lost (xfce4-session?).

The other option is to copy this file to ~/.config/xfce4/ and edit it there. This should override the one in /etc.

But strange that it didn't work in /etc/profile.d like it did for me.

Thank you.

Move /etc/xdg/xfce4/xintrc to ~/.config/xfce4/
What do you mean by "override". Will it prevent updates.?


What name did you give the file you created in /etc/profile.d ?

Last edited by Jakob77 (2023-05-06 07:25:06)

Offline

#12 2023-05-06 10:11:16

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,198

Re: How to add a folder to PATH.?

Jakob77 wrote:

Move /etc/xdg/xfce4/xintrc to ~/.config/xfce4/
What do you mean by "override". Will it prevent updates.?

No it won't prevent updates. That file will be used instead of the one at /etc/xdg/xfce4 so that if there is an update, your changes won't be lost.


What name did you give the file you created in /etc/profile.d ?

99-path.sh


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#13 2023-05-07 08:26:55

Jakob77
Member
Registered: 2022-11-03
Posts: 41

Re: How to add a folder to PATH.?

ToZ

I have now tested the filename "99-path.sh", and on my computer that also doesn't work.
You are right it is strange. Maybe it works for you because you run a Live session or booted up in system d, I don't know.

What ever modification we end up with we want it to be compatible with Xfce.
Are we coming closer to the point where you can confirm our modification as being that.
Or do you perhaps see a growing line of possible bugs showing up.?

Offline

#14 2023-05-08 08:57:51

Jerry3904
Member
Registered: 2013-11-09
Posts: 838

Re: How to add a folder to PATH.?

FWIW: MX uses yad (for a lot, actually) instead of zenity.

What ever modification we end up with we want it to be compatible with Xfce.

Not sure who "we" are in your statement, but that's not really true for MX, as this thread itself has demonstrated.


MX-21 (based on Debian Stable) with our flagship Xfce 4.18.

Offline

#15 2023-05-08 10:53:31

Jakob77
Member
Registered: 2022-11-03
Posts: 41

Re: How to add a folder to PATH.?

Jerry3904 wrote:

What ever modification we end up with we want it to be compatible with Xfce.

Not sure who "we" are in your statement, but that's not really true for MX, as this thread itself has demonstrated.

I am not sure what that means at all.
"We" normally just means more than one, and that is also the meaning here.
And this subject shows without any doubt that we want the modification to be compatible with Xfce (the main desktop for MX).

I don't see why we have to be concerned about a few crazy MX users who doesn't want MX mods to be compatible with Xfce.
If you are here to help their case I think you ought to find another subject for it.

Offline

#16 2023-05-08 10:56:27

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,198

Re: How to add a folder to PATH.?

Jakob77 wrote:

ToZ

I have now tested the filename "99-path.sh", and on my computer that also doesn't work.
You are right it is strange. Maybe it works for you because you run a Live session or booted up in system d, I don't know.

What ever modification we end up with we want it to be compatible with Xfce.
Are we coming closer to the point where you can confirm our modification as being that.
Or do you perhaps see a growing line of possible bugs showing up.?

Been doing some testing. profile.d doesn't work consistently in MXLinux. Tried in a second VM and it wouldn't work. Here is what did work:

  • Create the file ~/.config/xfce4/xinitrc with the following content:

    #!/bin/sh
    
    PATH=$PATH:$HOME/bin
    
    exec /etc/xdg/xfce4/xinitrc
  • Make the file executable:

    chmod +x ~/.config/xfce4/xinitrc
  • Log out and back in again

This xinitrc will override the system one, but it will only set the additional PATH entry then call the system script. This way, if the system script changes during an update, there will be no impact.

Jerry3904 wrote:

FWIW: MX uses yad (for a lot, actually) instead of zenity.

In that case, the script above could read:

echo $PATH | yad --text-info -

Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#17 2023-05-08 15:53:42

Jakob77
Member
Registered: 2022-11-03
Posts: 41

Re: How to add a folder to PATH.?

ToZ wrote:

Here is what did work:

  • Create the file ~/.config/xfce4/xinitrc with the following content:

    #!/bin/sh
    
    PATH=$PATH:$HOME/bin
    
    exec /etc/xdg/xfce4/xinitrc
  • Make the file executable:

    chmod +x ~/.config/xfce4/xinitrc
  • Log out and back in again

This xinitrc will override the system one, but it will only set the additional PATH entry then call the system script. This way, if the system script changes during an update, there will be no impact.



Thank you very much. That is great. :-)

I had to reboot, but I have tested it with good results in MX 21.3.

The only downside I see compared to the other solution
https://forum.xfce.org/viewtopic.php?pid=71816#p71816
is that it doesn't work for all users. It only works for the specific user that received the modification.

But of course that won't be a problem if it is build in MX install, so it automatically comes along when a new user is created.

Last edited by Jakob77 (2023-05-08 16:06:49)

Offline

#18 2023-05-15 07:21:16

Jakob77
Member
Registered: 2022-11-03
Posts: 41

Re: How to add a folder to PATH.?

ToZ


I want to thank you again and ask a little more about

~/.config/xfce4/xinitrc

#!/bin/sh

PATH=$PATH:$HOME/bin

exec /etc/xdg/xfce4/xinitrc


I am not very good at scripting and I am not familiar with the shell so I want to ask before I do something too stupit to the file.

Can I for instance add lines like theese to the file so ~/bin only will be added to PATH if the folder exists:


# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

and then afterwards add more folders.?


So it could end up looking something like this:


#!/bin/sh

# set Xfce PATH so it includes user's private bin first in line if it exists

if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi


# add folder "~/scripts" in the end of Xfce PATH

     PATH=$PATH:$HOME/scripts

     exec /etc/xdg/xfce4/xinitrc

Offline

#19 2023-05-15 10:30:15

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,198

Re: How to add a folder to PATH.?

Absolutely, and that makes good sense. Only add the folder to the path if it exists. You can do the same with the scripts folder.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

Board footer

Powered by FluxBB