Session Environment Variables/da: Difference between revisions

From KDE UserBase Wiki
No edit summary
(Updating to match new version of source page)
Line 3: Line 3:
== Sætning af sessionsmiljøvariable ==
== Sætning af sessionsmiljøvariable ==


Det er enkelt at sætte miljøvariable, som påvirker hele din session. KDE vil udføre ethvert script med filendelse <tt>.sh</tt>, som den finder i <tt>$HOME/.kde/env</tt> og vil vedligeholde alle de miljøvariable, som sættes heri. Det er vigtigt, at enhver variabel, som du vil sætte også bliver ''eksporteret''. Som eksempel er PATH en miljøvariabel, som dit system har sat op med stien til de mapper, som mest sandsynligt indeholder ting, som systemet skal finde. Nu vil du tilføje endnu en mappe. Du kan se, hvad der allerede er i variablen ved at åbne [[Special:myLanguage/Konsole|Konsole]] og skrive <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>


For at føje stier til din [http://en.wikipedia.org/wiki/Path_(computing) PATH] skal du blot lave en fil ved navn <tt>$HOME/.kde/env/path.sh</tt> med et indhold i retning af dette:
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
}}
}}


Du kan også se, hvordan KDE faktisk gør det. Det sker i din lokale udgave af <code>startkde</code>, som du normalt kan finde i <tt>/usr/bin/startkde</tt>. Hvis du er interesseret i at læse koden, så kan du se den [https://projects.kde.org/projects/kde/kde-workspace/repository/revisions/master/entry/startkde.cmake online]. Søg blot i filen efter ''environment variables''.
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:System/da]]
[[Category:System/da]]

Revision as of 20:50, 4 November 2016

Sætning af sessionsmiljøvariable

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

Lad os se, hvad der sker her. Kommandoen export fortæller systemet, at dette er noget, som skal gemmes og bruges, når der søges efter filer. Herefter kommer den fulde sti til den mappe, som du ønsker at tilføje (i dette tilfælde ~/local/bin, hvilket er en anden måde at skrive /home/you/local/bin - nu kan du igen bruge echo $HOME til at se, hvordan det virker). Endelig ser du selve variablen, $PATH - det er fordi du føjer din nye sti til det eksisterende indhold i stedet for at overskrive det.

Ofte vil dette fungere godt nok for dig, men efterhånden som du bliver mere fortrolig med systemet, vil du nok ønske at have det samme miljø når du bruger en konsol eller tilgår maskinen via ssh; så skal du føje noget i retning af dette til slutningen af din .bashrc:

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.