Xfce Forum

Sub domains
 

You are not logged in.

#1 2019-01-12 00:33:36

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 862

How can I set the PATH ...?

how can i set the PATH environment variable that Xfce will run with?  i would like to have scripts in a distinct directory be run by Xfce.  i noticed PATH did not have the directory i want to have the scripts in.  for a bash terminal session, i can have appropriate commands in .bashrc to set PATH.

Offline

#2 2019-01-12 01:37:42

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

Re: How can I set the PATH ...?

Some hits from a web search on "How can I set the PATH environmemt variable"

https://unix.stackexchange.com/question … th-to-path
https://www.techrepublic.com/article/ho … -in-linux/


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

Offline

#3 2019-01-12 02:56:32

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 862

Re: How can I set the PATH ...?

those tell how to do it for a shell session, like in a terminal.  but what i need is how to set it in Xfce.  there maybe a shell script that starts up Xfce.  if there is it could be done there with the shell export subcommand.  but, the right way may be different; it may be some config setting in a file that Xfce reads.

Offline

#4 2019-01-12 12:53:25

alcornoqui
Member
Registered: 2014-07-28
Posts: 832

Re: How can I set the PATH ...?

Offline

#5 2019-01-12 14:03:50

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,485

Re: How can I set the PATH ...?

Skaperen wrote:

those tell how to do it for a shell session, like in a terminal.  but what i need is how to set it in Xfce.  there maybe a shell script that starts up Xfce.  if there is it could be done there with the shell export subcommand.  but, the right way may be different; it may be some config setting in a file that Xfce reads.

This really isn't an Xfce issue. Let me explain why.

Xfce is a user-space desktop environment which means that it only starts up after a user has logged in (manually from a tty or via a display manager). By this time, the system has already set the default $PATH. Xfce and all of it's components will use this $PATH.

So if you want to change your distro's $PATH, you need to edit it's configuration files. This will/may vary from distro to distro. Ubuntu for example, has $HOME/bin and $HOME/.local/bin already included in it's default path (at least for 16.04 it does) - which is set in /etc/skel/.profile and copied to each users $HOME/.profile on account creation. So the easy answer is to use one of those directories.

If you want to add another directory to the path, then you need to edit your system files or alternatively, use the advice that Jerry provided above.


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

#6 2019-01-12 15:16:46

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 862

Re: How can I set the PATH ...?

> This really isn't an Xfce issue. Let me explain why.

i figured PATH was set before Xfce started.

so what i would be looking for is either how that PATH is set (not in Xfce) or how Xfce is started.  and what i mean by "how ... is started" is not what starts it (such as the display manager), but what steps it goes through to start it.  perhaps all it does is execute (via an appropriate system exec??() syscall) some specific path.  part of "how" would be where it gets that path from.  maybe that is a registration database.  or maybe it's a directory of symlinks that can be looked through for regular expression matches.  or maybe that directory with exact session name symlinks.  i can imagine many possible ways.

maybe it's /usr/bin/startxfce4.

if i know a fixed file path where Xfce is always started at what i can do is "wedge it".  that means renaming it to an alternate name and replacing the original name with a script that sets or modifies the PATH environment variable, then executes the alternate name the original file was renamed to.

or, perhaps, the start file is a script that can be modified.

if it were a binary executable compiled from a language like C or C++ then either the source can be modified and compiled and linked appropriately, or the wedge method would be used.

Last edited by Skaperen (2019-01-12 15:18:33)

Offline

#7 2019-01-22 11:06:14

sh4tr
Member
Registered: 2014-03-20
Posts: 32

Re: How can I set the PATH ...?

.local/bin/

anyway, session and start up > application autostart

Offline

#8 2019-01-22 23:09:43

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 862

Re: How can I set the PATH ...?

sh4tr wrote:

.local/bin/

anyway, session and start up > application autostart

i didn't explain my intent, very well.  i'll try again with more focused detail:

1.  i want to move the first thing to run for xfce to another name.  i can append "-original" at the end of the name.  so if that name is "xfce4-start" then it would become "xfce4-start-original".

2.  then i will put my own script in the name that was left absent by the move of step 1.

3.  the script in step 2 will do two things:

3A.  it will set the PATH environment variable to include the path to my scripts.

3B.  it will execute the program renamed in step 1.

#!/bin/bash
export PATH="/usr/host/xfce4/bin:$PATH"
exec "$0-original" "$@"

what i need to know, in order to do this, is what is the real path of the executable file that starts up xfce so i know where to insert my wedge script.

Offline

#9 2019-01-23 00:14:32

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,485

Re: How can I set the PATH ...?

Skaperen wrote:

what i need to know, in order to do this, is what is the real path of the executable file that starts up xfce so i know where to insert my wedge script.

Since you are using lightdm as your display manager, it will start via the associated .desktop file in /usr/share/xsessions. This will most probably be the /usr/bin/startxfce4 script.


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

#10 2019-01-23 01:10:20

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 862

Re: How can I set the PATH ...?

when you "start" a .desktop file. is there some special interpreter?  back when i had some designation files like that for another project, i really did have an interpreter for them, and those files began with a hash-bang (#!) naming the interpreter.  thus, they could be directly executed.

Offline

#11 2019-01-24 00:40:54

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,485

Re: How can I set the PATH ...?

When I run "pstree" on my system (that is running lightdm) I get the following snippet:

        ├─lightdm─┬─Xorg───2*[{Xorg}]
        │         ├─lightdm─┬─sh───xfce4-session─┬─applet.py

So in this case, the interpreter is sh (bourne shell). This is outside the scope of Xfce.


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

#12 2019-01-29 23:43:45

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 862

Re: How can I set the PATH ...?

when you say "...it will start via the associated .desktop file ..." that may not make it be an Xfce issue, but it gets close.  the next question is then how to "run" a .desktop file.  do i need to parse it and run the command given in the "Exec=" assignment?  what about the other info?  or is there some other way to deal with .desktop files?

i could put my wedge in front of the executable that "Exec=" specifies.  that might depend on what is being run.  it might execute an interpreter and an interpreted script that has no hash-bang line.  but wedging the interpreter would br wrong.  if i knew more about it, wedging the .desktop file might be the way to go (for example, how can a .desktop file refer to another .desktop file).

Offline

#13 2019-01-30 00:44:06

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,485

Re: How can I set the PATH ...?

Skaperen wrote:

when you say "...it will start via the associated .desktop file ..." that may not make it be an Xfce issue, but it gets close.  the next question is then how to "run" a .desktop file.  do i need to parse it and run the command given in the "Exec=" assignment?  what about the other info?  or is there some other way to deal with .desktop files?

A better way to say this would have been to "process" the .desktop file. In the case of execution, it would run the program in the "Exec=" line. You don't need to run it or do anything with it. In the perspective of this thread, lightdm will process the .desktop file and run the command in the "Exec="line.

i could put my wedge in front of the executable that "Exec=" specifies.  that might depend on what is being run.  it might execute an interpreter and an interpreted script that has no hash-bang line.  but wedging the interpreter would br wrong.  if i knew more about it, wedging the .desktop file might be the way to go (for example, how can a .desktop file refer to another .desktop file).

To answer the second part first, you can use exo-open to process a .desktop file:

exo-open /usr/share/applications/xfce4-screenshooter.desktop

You could put a wedge in the Exec= line but a better way to do it would be to override the existing binary. For example, assume your $PATH statement has "/usr/local/bin" preceding "/usr/bin" as is the case for me:

 $ echo $PATH
/home/toz/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

And if the .desktop file has for example:

$ cat /usr/share/applications/xfce4-screenshooter.desktop | grep "Exec="
Exec=xfce4-screenshooter

And xfce4-screenshooter exists in /usr/bin:

$ which xfce4-screenshooter
/usr/bin/xfce4-screenshooter

You could create a /usr/local/bin/xfce4-screenshooter file that will be executed in lieu of the one in /usr/bin effectively overriding it. From within this file you can perform some task then execute the real binary:

#!/bin/bash

# do some of my stuff first
exec /usr/bin/xfce4-screenshooter

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

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.016 seconds, 8 queries executed - Memory usage: 601.8 KiB (Peak: 618.64 KiB) ]