# Mechanics of Settings App

<figure><img src="https://1453621892-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyhORwVwuIgJMLsQRqN3S%2Fuploads%2FUt07Kvd2UPlCbYOvMD4w%2Fimage.png?alt=media&#x26;token=17821cca-6644-4d0b-a58e-8298b6367ee5" alt=""><figcaption></figcaption></figure>

The Settings application displays all the available sections on the first page and the available configuration options inside it on the second page. But, how?

The Settings application uses the embedded JSON file inside the kernel to provide it the available configuration options inside each section. Reading these files are done by the Settings app upon starting it up using the `settings` command with their appropriate switches in the previous page.

The format of all the settings can be found in the below link.

{% content-ref url="settings-format" %}
[settings-format](https://aptivi.gitbook.io/aptivi/nitrocid-ks-manual/advanced-and-power-users/inner-workings/kernel-settings/settings-format)
{% endcontent-ref %}

***

## <mark style="color:$primary;">The mechanism</mark>

Here's how the settings application works:

{% stepper %}
{% step %}

### <mark style="color:$primary;">Loads the configuration</mark>

When the settings application is loaded, it loads one of these files to the cached settings entry object to be used. The application then tries to list all the sections passed to it.
{% endstep %}

{% step %}

### <mark style="color:$primary;">Populates the settings entries</mark>

If the user enters a section, the app will make a list of each available settings entry found in the `Keys` variable with their values, queried by the `ConfigTools.GetValueFromEntry()` function in the `Nitrocid.Kernel.Configuration` namespace.
{% endstep %}

{% step %}

### <mark style="color:$primary;">Determines the value type</mark>

When the user changes a value in the selected entry, the settings application determines what to do based on the type and gives the user an option to input the new value. The next page actually explains what to do based on the type.
{% endstep %}

{% step %}

### <mark style="color:$primary;">Sets the value</mark>

When the user sets a new value, the app attempts to set a value by delegating the `PropertyManager.SetPropertyValue()` function in the `Nitrocid.Misc.Reflection` namespace.
{% endstep %}
{% endstepper %}

When the user is done configuring the kernel to their needs, they'll save the kernel configuration. The app invokes the `Config.CreateConfig()` function to save the changes to the configuration file.

The CLI version of the settings, which hosts the four commands as explained in the Kernel Settings page, uses a bunch of settings tools, including `GetSettingsKey()` that allows you to quickly get a settings key containing settings key information for a specified variable. This key is usable for useful functions, like setting a variable to a specified value that `setconfigvalue` is doing.
