How do I programmatically enable a view mode? Let's say I have created a new view mode with DS. How can I activate it programmatically?

I want to achieve this because I'm doing an export with features but, despite the Features module exports DS settings and layouts, it does not automagically activate them. I'm planning to active this new display inside an install hook or something like that.

I looked in the tables schema, but I could not tell what activates a view mode.
Use following code to enable view mode programmatically in Drupal 7:

module_load_include('inc', 'field_ui', 'field_ui.admin');
$bundle_settings = field_bundle_settings('ENTITY TYPE', 'BUNDLE');
$bundle_settings['view_modes']['VIEW MODE']['custom_settings'] = TRUE;
field_bundle_settings('ENTITY TYPE', 'BUNDLE', $bundle_settings);


Replace ENTITY TYPE, BUNDLE, VIEW MODE with your values.