The idea was to have a single write_config call behind this.
So basically you call the function and keep track of the dirty state through a variable and test that.
After that you call write_config() to avoid having to generate 2 events on config change for the same thing.