Skip to content

Have Plugins be able to update TR Config#1098

Open
robotastic wants to merge 2 commits intomasterfrom
dev/plugin-config
Open

Have Plugins be able to update TR Config#1098
robotastic wants to merge 2 commits intomasterfrom
dev/plugin-config

Conversation

@robotastic
Copy link
Copy Markdown
Collaborator

There is probably a lot of fun that you could have with this. What do you think of the approach? Any setting missing?

@Dygear
Copy link
Copy Markdown
Contributor

Dygear commented Mar 3, 2026

I didn't see a function that will do a config write out. I was thinking something along the lines of:

config_write / config_save that overwrites the current config file. What ever name you choose, if you decide to implement would be to allow you to write the config file to drive.

Param: bool backup - Default false, is no backup of config. true is backup the current config file before overwriting it.
Param: string filename - Default NULL so it saves the config with the current loaded filename + .old. Otherwise follows the same formatting rules as what is used for the new filename parser for the wav / json / m4a files.
config_write(bool backup = false, ?string filename = NULL)

@taclane
Copy link
Copy Markdown
Contributor

taclane commented Mar 4, 2026

I didn't see a function that will do a config write out. I was thinking something along the lines of:

config_write / config_save that overwrites the current config file. What ever name you choose, if you decide to implement would be to allow you to write the config file to drive.

Param: bool backup - Default false, is no backup of config. true is backup the current config file before overwriting it. Param: string filename - Default NULL so it saves the config with the current loaded filename + .old. Otherwise follows the same formatting rules as what is used for the new filename parser for the wav / json / m4a files. config_write(bool backup = false, ?string filename = NULL)

There's honestly nothing stopping a plugin from doing so already. As long as the user invoking t-r has write access to the config file, a plugin can read/write to it using basic file operations. I've been experimenting with this in the tr-web plugin to edit the config file over http and then send a signal to restart trunk-recorder.

@Dygear
Copy link
Copy Markdown
Contributor

Dygear commented Mar 5, 2026

I was thinking there should be a canonical way of doing it from within the system. So that plugin devs don't have the implement this perhaps poorly (I'm talking about myself here) many times. Namely to make sure that it respects config file rules with not setting a value if it's default in the json file, or having plugins have their own config file settings preserved by the system having the full view of everything.

@robotastic
Copy link
Copy Markdown
Collaborator Author

good points @Dygear - it would be better to implement it once, correctly. It maybe a little tricky to not have the Default values trickle into the file.

@robotastic
Copy link
Copy Markdown
Collaborator Author

added in the ability for plugins to save the current configuration to a config.json file. it tracks the current JSON values so you do not get all of the default values saved to the file.

@Dygear
Copy link
Copy Markdown
Contributor

Dygear commented Apr 1, 2026

This should make it in for the next version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants