Session Environment Variables: Difference between revisions
(replace startkde with startplasma-x11/startplasma-wayland; replace bad link to cgit,) |
(Marked this version for translation) |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 11: | Line 11: | ||
<!--T:4--> | <!--T:4--> | ||
{{Input|1=export PATH=$HOME/local/bin:$PATH | {{Input|1=export PATH=$HOME/.local/bin:$PATH | ||
}} | }} | ||
<!--T:5--> | <!--T:5--> | ||
Let's explore that. The command ''export'' tells the system that this is something that should be saved and used when looking for files. Next you add the full name of the directory you want to add (in this case <tt>$HOME/local/bin</tt>). Finally you see the $PATH variable itself - that's because you want to add your new path into it, not replace the existing path. | Let's explore that. The command ''export'' tells the system that this is something that should be saved and used when looking for files. Next you add the full name of the directory you want to add (in this case <tt>$HOME/.local/bin</tt>). Finally you see the $PATH variable itself - that's because you want to add your new path into it, not replace the existing path. | ||
{{Warning|If you want to point your home don't use '~', use $HOME instead}} | {{Warning|If you want to point your home don't use '~', use $HOME instead}} | ||
Line 28: | Line 28: | ||
<!--T:8--> | <!--T:8--> | ||
You can also check how Plasma actually does it. KDE startup is complicated, it ends up calling either <tt>/usr/bin/startplasma-x11</tt> or <tt>/usr/bin/startplasma-wayland</tt>. If you are interested in reading the code, you can can view [https://invent.kde.org/plasma/plasma-workspace/-/blob/master/startkde/startplasma.cpp#L258 the startkde code online]; search for ''environment variables''. | You can also check how Plasma actually does it. KDE startup is complicated, it ends up calling either <tt>/usr/bin/startplasma-x11</tt> or <tt>/usr/bin/startplasma-wayland</tt>. If you are interested in reading the code, you can can view [https://invent.kde.org/plasma/plasma-workspace/-/blob/master/startkde/startplasma.cpp#L258 the startkde code online]; search for ''environment variables''. | ||
<!--T:10--> | |||
== See also == | |||
{{Menu|System Settings|Startup and Shutdown|Autostart}} shows what scripts and applications run and lets you add new ones; see [[Special:myLanguage/System Settings/Startup and Shutdown|Startup and Shutdown]]. | |||
<!--T:9--> | <!--T:9--> |
Latest revision as of 12:03, 18 March 2024
Setting Session Environment Variables
It is simple to set environment variables that affect your whole session. Plasma will execute any script it finds in $HOME/.config/plasma-workspace/env whose filename ends in .sh, and it will maintain all the environment variables set by them. It is important that any variable you want to set must be also exported
. In the case of PATH, for instance, your system will be set up with certain likely directories as the likely places to find things. Now you are adding an extra possible search place. You can see what is already set by opening Konsole and typing echo $PATH
To add paths to your PATH, simply create a file named $HOME/.config/plasma-workspace/env/path.sh with a contents similar to this:
export PATH=$HOME/.local/bin:$PATH
Let's explore that. The command export tells the system that this is something that should be saved and used when looking for files. Next you add the full name of the directory you want to add (in this case $HOME/.local/bin). Finally you see the $PATH variable itself - that's because you want to add your new path into it, not replace the existing path.
Often that will work well enough for you, but as you get more familiar with the system you will probably want to have the same environment when using a console or accessing your machine via ssh, you will need to add to the end of your .bashrc something like this:
source $HOME/.config/plasma-workspace/env/path.sh
You can also check how Plasma actually does it. KDE startup is complicated, it ends up calling either /usr/bin/startplasma-x11 or /usr/bin/startplasma-wayland. If you are interested in reading the code, you can can view the startkde code online; search for environment variables.