Session Environment Variables/ca: Difference between revisions

From KDE Wiki Sandbox
(Importing a new version from external source)
(Updating to match new version of source page)
Line 3: Line 3:
== Definir les variables d'entorn de la sessió ==
== Definir les variables d'entorn de la sessió ==


Configurar les variables d'entorn que afecten a tota la sessió és fàcil. El KDE executa qualsevol script que troba a <tt>$HOME/.kde/env</tt> si el nom acaba en <tt>.sh</tt>, i mantindrà totes les variables d'entorn establertes per aquests. És important que qualsevol altra variable que vulgueu establir també sigui <code>exported</code>. En el cas de PATH, per exemple, el sistema es configurarà amb certs directoris on probablement siguin els llocs on trobar les coses. Ara afegireu un lloc addicional de cerca. Podeu veure el que ja està establert obrint [[Special:myLanguage/Konsole|Konsole]] i escrivint <code>echo $PATH</code>
It is simple to set environment variables that affect your whole session. KDE will execute any script it finds in <tt>$HOME/.config/plasma-workspace/env</tt> whose filename ends in <tt>.sh</tt>, and it will maintain all the environment variables set by them. It is important that any variable you want to set must be also <code>exported</code>. 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 [[Special:myLanguage/Konsole|Konsole]] and typing <code> echo $PATH</code>


Per afegir camins a la vostra [http://en.wikipedia.org/wiki/Path_(computing) PATH], només cal crear un fitxer anomenat <tt>$HOME/.kde/env/path.sh</tt> amb un contingut similar a aquest:
To add paths to your [http://en.wikipedia.org/wiki/Path_(computing) PATH], simply create a file named <tt>$HOME/.config/plasma-workspace/env/path.sh</tt> with a contents similar to this:


{{Input|1=export PATH=$HOME/local/bin:$PATH
{{Input|1=export PATH=$HOME/local/bin:$PATH
Line 15: Line 15:


{{Input|1=
{{Input|1=
source $HOME/.kde/env/path.sh
source $HOME/.config/plasma-workspace/env/path.sh
}}
}}


També podeu comprovar com ho fa realment el KDE. Ho fa en el vostre <code>startkde</code> local, que normalment es troba a <tt>/usr/bin/startkde</tt>. Si esteu interessat en la lectura del codi, el podeu veure [https://projects.kde.org/projects/kde/kde-workspace/repository/revisions/master/entry/startkde.cmake en línia]. Només heu de cercar al fitxer les ''variables d'entorn''.
You can also check how KDE actually does it. It's done in your local <code>startkde</code>, which normally you can find in <tt>/usr/bin/startkde</tt>. If you are interested in reading the code, you can can view it [https://quickgit.kde.org/?p=plasma-workspace.git&a=blob&f=startkde%2Fstartkde.cmake online]. Just search the file for ''environment variables''.


[[Category:Sistema/ca]]
[[Category:Sistema/ca]]

Revision as of 20:50, 4 November 2016

Definir les variables d'entorn de la sessió

It is simple to set environment variables that affect your whole session. KDE 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

Anem a explorar això. L'ordre export li indica al sistema que es tracta d'una cosa que s'ha de desar i utilitzar en la cerca de fitxers. A continuació, afegeix el nom complet del directori que es vol afegir (en aquest cas ~/local/bin, una altra manera d'escriure /home/vos/local/bin -una vegada més podeu utilitzar echo $HOME per veure com funciona-). Finalment, veureu la mateixa variable $PATH -aquesta contindrà el nou camí a dins, no substituirà els camins existents-.

Encara que funcioni prou bé, a mesura que us familiaritzeu amb el sistema és probable que vulgueu tenir el mateix ambient quan utilitzeu una consola o accediu a la vostra màquina a través de ssh, haureu d'afegir al final del vostre .bashrc alguna cosa com això:

source $HOME/.config/plasma-workspace/env/path.sh

You can also check how KDE actually does it. It's done in your local startkde, which normally you can find in /usr/bin/startkde. If you are interested in reading the code, you can can view it online. Just search the file for environment variables.