I am experimenting with theme building and I wonder how can I get settings for a specific block in current layout?

For instance I want to change header template depending on what kind of menu is set in header block settings. I am using hook_preprocess_header(&$variables) for that. What function(s) should I use to get header block settings? There seem to be no cue in $variables.

Comments

I found that I can take block settings by getting access to current layout and then finding required block in it. Not sure if this is the optimal way of doing that, but seems to work at least. Below I am getting access to menu name that is set in header block.

function HOOK_preprocess_header(&$variables) {

$blocks = layout_get_layout_by_path()->content;

  foreach ($blocks as $block) {
    if ($block->plugin == 'system:header') {
      $menu_name = $block->settings['block_settings']['menu'];
    }
  }
}