
\begin{DoxyItemize}
\item infos = Information about the profile plugin is in keys below
\item infos/author = Thomas Waser \href{mailto:thomas.waser@libelektra.org}{\tt thomas.\+waser@libelektra.\+org}
\item infos/licence = B\+SD
\item infos/needs =
\item infos/provides =
\item infos/recommends =
\item infos/placements = postgetstorage presetstorage
\item infos/status = maintained libc nodep global preview unfinished
\item infos/metadata =
\item infos/description = helps switching between configuration profiles
\end{DoxyItemize}

Following the elektra keyname convention application configurations are stored under {\ttfamily /sw/org/myapp/\#} and {\ttfamily /sw/org/myapp/\#0/current}is the profile to be used. The {\ttfamily profile} plugin provides an easy way to switch configuration profiles.

The key {\ttfamily /sw/org/myapp/\#0/profile} defines what profile should be used as {\ttfamily current}, e.\+g. {\ttfamily /sw/org/myapp/\#0/profile = myprofile}. If a key {\ttfamily /sw/org/myapp/\#0/myprofile/key} is found and no key {\ttfamily /sw/org/myapp/\#0/current/key} exists an override key will be created linking {\ttfamily /sw/org/myapp/\#0/currrent/key} to {\ttfamily /sw/org/myapp/\#0/myapp/key} If neither {\ttfamily /sw/org/myapp/\#0/current/key} nor {\ttfamily /sw/org/myapp/\#0/myprofile/key} is found, but {\ttfamily /sw/org/myapp/\#0/\%/key}, {\ttfamily /sw/org/myapp/\#0/current/key} will be linked to {\ttfamily /sw/org/myapp/\#0/\%/key}.

So a cascading lookup will automatically implement following preferences (next to the namespace preferences)\+:


\begin{DoxyEnumerate}
\item Usage of key in {\ttfamily current}
\item Usage of key in the profile set with {\ttfamily profile}
\item Usage of key in the {\ttfamily \%} fallback profile
\end{DoxyEnumerate}

\subsection*{Example}

Suppose we have the configuration file {\ttfamily profile.\+ini} in {\ttfamily $\sim$/.config}\+: \begin{DoxyVerb}% cat profile.ini
[]
profile = myprofile

[current]
key2 = will win

[myprofile]
key1 = test1
key2 = test2

[%]
key2 = failed?
key3 = test3
\end{DoxyVerb}


Then we simply mount it {\itshape without} the profile plugin\+: \begin{DoxyVerb}% kdb mount profile.ini /sw/org/myapp/#0 ini
\end{DoxyVerb}


But we have to make sure that the profile plugin is mounted globally\+: \begin{DoxyVerb}% kdb global-mount profile
\end{DoxyVerb}


Then we can access {\ttfamily /sw/org/myapp/\#0} in a profile-\/aware way\+: \begin{DoxyVerb}% kdb ls /sw
spec/sw/org/myapp/#0/current/key1
spec/sw/org/myapp/#0/current/key3
user/sw/org/myapp/#0
user/sw/org/myapp/#0/%
user/sw/org/myapp/#0/%/key2
user/sw/org/myapp/#0/%/key3
user/sw/org/myapp/#0/current
user/sw/org/myapp/#0/current/key2
user/sw/org/myapp/#0/profile
user/sw/org/myapp/#0/myprofile
user/sw/org/myapp/#0/myprofile/key1
user/sw/org/myapp/#0/myprofile/key2
\end{DoxyVerb}


As we can see with the {\ttfamily -\/v} option, we will fetch keys from our {\ttfamily myprofile} even though we request {\ttfamily current}\+: \begin{DoxyVerb}% kdb get -v /sw/org/myapp/#0/current/key1
got 25 keys
searching spec/sw/org/myapp/#0/current/key1, found: spec/sw/org/myapp/#0/current/key1, options: KDB_O_CALLBACK
The resulting keyname is user/sw/org/myapp/#0/myprofile/key1
test1
\end{DoxyVerb}


To switch profile we simply have to set one key\+: \begin{DoxyVerb}kdb set user/sw/org/myapp/#0/profile newprofile
\end{DoxyVerb}


Usually, this will be done via commandline by setting {\ttfamily proc/sw/org/myapp/\#0/profile}. 