Is there a theme equivalent of hook_install()? I want my theme to control certain block settings, like which elements of the system branding block are enabled. To me it makes sense for that to be code in the theme, not a module, because at the moment the only way I've found to access the config programmatically involves using the theme name.

/** @var Drupal\Core\Config\Config $config */
$config = \Drupal::service('config.factory')-&gt;getEditable('block.block.my_theme_branding');
$config-&gt;set('settings.use_site_logo', false);
$config-&gt;save();


Since this is a one off config change, I think it should only happen when the theme is installed/activated. It there a theme function/hook that behaves like hook_install does for modules?
You may provide configuration via YAML files as part of a module, profile or theme install by adding them to the config/install directory inside the respective project. So, for example, a file block.block.my_theme_branding.yml would install the branding block into the specified region. This would then contain the setting to disable the site slogan by default. Take a look at block.block.bartik_branding.yml in the standard profile as a starting point.

If the specific block is provided by another module, then it should probably be placed in the config/optional directory.