How to access individual theme settings from code? I was building a block for which I have to provide bubblable metadata. The data in this block is depending on individual theme configurations as well as the global theme settings. 

So I tried the following:

$config = \Drupal::config('system.theme.global');
$bubbleable_metadata-&gt;addCacheableDependency($config);

$config2 = \Drupal::config('bartik.settings');
$bubbleable_metadata-&gt;addCacheableDependency($config2);


This however obviously does not work if the theme is not set to bartik. I have been attempting to find the theme configuration in \Drupal::theme()-&gt;getActiveTheme(), but that does not provide this data. 

I suppose I could try $config = \Drupal::theme()-&gt;getActiveTheme()-&gt;getName() . '.settings';, but I'd like to learn if there are better ways.

How to get the configuration (or config name) of the current active theme?
It seems this is actually the recommended way. It is used in theme_get_settings() as well:

$theme = \Drupal::theme()-&gt;getActiveTheme()-&gt;getName();
...
  if ($theme_settings = \Drupal::config($theme . '.settings')-&gt;get()) {
    ...
  }