Skip to main content
Topic: Local path ingnored [SOLVED] (Read 433 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Local path ingnored [SOLVED]

Here on Artix I don't see a ~/.profile so I guess it is not sourced.
I put in ~/.bash_profile and in ~/.bashrc the paths:
Code: [Select]
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi
That works when I open a terminal but not for sxhkd or dmenu.

In what file should I put them?

Re: Local path ingnored

Reply #1
Adding your home path like that is a big security hole, because unprivileged processes can put a pseudo command which will overwrite the system one, so say you think you run "ls" but you might run "ls" in your .local/bin which was put there by malware - unlikely, but anyway, it should go after the other existing paths. If you want your own scripts to be globally available on the system, you can use /usr/local/bin which requires superuser permissions to write to. Also things from there can be links to anywhere, including your home dir if you wanted, although more likely you would install your own system wide things in /opt. But for the precise answer to your question if you really wanted to do it like that - I don't know exactly, perhaps someone else does!

Re: Local path ingnored

Reply #2
Please check out Environment variables.

Quote
In this example, we will create a function to add several directories (e.g. ~/bin and ~/scripts) to PATH for the respective user. To do this, just put this in your preferred global environment variable configuration file (/etc/profile or /etc/bash.bashrc)
Code: [Select]
set_path(){

    # Check if user id is 1000 or higher
    [ "$(id -u)" -ge 1000 ] || return

    for i in "$@";
    do
        # Check if the directory exists
        [ -d "$i" ] || continue

        # Check if it is not already in your $PATH.
        echo "$PATH" | grep -Eq "(^|:)$i(:|$)" && continue

        # Then append it to $PATH and export it
        export PATH="${PATH}:$i"
    done
}

set_path ~/bin ~/scripts
You would have to modify the paths to your specifications.

Quote
/etc/profile initializes variables for login shells only. It does, however, run scripts (e.g. those in /etc/profile.d/) and can be used by all Bourne shell compatible shells.
Or you could create a custom profile script in /etc/profile.d/<script>.sh.

Re: Local path ingnored

Reply #3
I created a custom profile script in /etc/profile.d/<script>.sh, it works for sxhkd but not for dmenu.

So maybe is it something specific to dmenu?
Or from the Arch wiki:
Quote
Note: The dbus daemon and the user instance of systemd do not inherit any of the environment variables set in places like ~/.bashrc etc. This means that, for example, dbus activated programs like GNOME Files will not use them by default. See systemd/User#Environment variables.

Also /etc/profile doesn't affect it.
I am using "dmenu_run".


 

Re: Local path ingnored

Reply #5
dmenu needs /etc/enviroment or ~/.xsession.

I am using a dm to start the GUI, ~/.xinitrc is ignored.
Only nodm uses it since it is some kind of wrapper for startx.

sxkbd needs /etc/profile.d/script, I guess /etc/profile is fine too.

So I am using /etc/enviroment and /etc/profile.d/script, those should work on wayland too.