Set the Value of a Persistent Setting
You can interact with app, extension, and user settings using the ISettings
interface from the carb.settings
module. Persistent settings are saved between app sessions. This means that a user can close the app and retrieve the same settings when the app is relaunched. You can identify persistent settings because their key will start with /persistent
. This snippet shows how to set the value of a new or existing persistent setting.
Note
Each extension puts settings in /ext/[ext_name]/
to not conflict with settings from other extensions. Extensions should also list their settings in their extension.toml
to make the settings discoverable to users and developers.
import carb.settings
settings = carb.settings.get_settings()
# all settings stored under "/persistent" saved between sessions
key = "/persistent/exts/your.ext.name/test/value"
print("{}: {}".format(key, settings.get(key)))
settings.set(key, "string from previous session")
# Below is a setting with location of a file where persistent settings are stored.
# To reset settings: delete it or run kit with `--reset-user`
print("persistent settings are stored in: {}".format(settings.get("/app/userConfigPath")))