# Path: kano_settings/system/audio.py
# def set_to_HDMI(HDMI, force=False):
#     '''
#     Set audio output to HDMI if supported by the display,
#     otherwise set it to Analogue output.
# 
#     Returns 'HDMI' or 'Analogue', whichever was applied.
#     '''
# 
#     if not is_hdmi_audio_supported() and not force:
#         HDMI = False
# 
#     # 1 analog
#     # 2 hdmi
# 
#     # These are the changes we'll apply if they have changed from what they were
#     if HDMI:
#         amixer_cmd = hdmi_cmd
#         set_config_value('hdmi_ignore_edid_audio', None)
#         set_config_value('hdmi_drive', 2)
#         config = _("HDMI")
#     else:
#         amixer_cmd = analogue_cmd
#         set_config_value('hdmi_ignore_edid_audio', 1)
#         set_config_value('hdmi_drive', None)
#         config = _("Analogue")
# 
#     end_config_transaction()
# 
#     # Set audio path in amixer
#     o, e, rc = run_cmd(amixer_cmd)
#     if rc:
#         logger.warn("error from amixer: {} {} {}".format(o, e, rc))
# 
#     # trigger alsa-store to store the path in /var/lib/alsa/asound.state
#     o, e, rc = run_cmd(store_cmd)
#     if rc:
#         logger.warn("error from alsa-store: {} {} {}".format(o, e, rc))
# 
#     set_setting('Audio', config)
#     return config
# 
# Path: kano_settings/boot_config.py
# def set_config_value(self, name, value=None, config_filter=Filter.ALL):
#     self.set_state_writable()
#     self.temp_config.set_value(name, value, config_filter)
# 
# Path: kano_settings/boot_config.py
# def end_config_transaction():
#     _trans().close()
# 
# Path: kano_settings/system/overclock.py
# def set_default_overclock_values(board_name=None):
#     board = get_board_props(board_name=board_name)
# 
#     if not board:
#         logger.error("Could not get overclocking settings for board")
#         return
# 
#     change_overclock_value(board.CLOCKING['default'], board_name)
# 
# Path: kano_settings/system/keyboard_config.py
# def set_keyboard(locale_code, variant, save=False):
#     if variant == 'generic':
#         variant = ''
# 
#     # Notify and apply changes to the XServer
#     run_cmd("setxkbmap {} {}".format(locale_code, variant))
#     set_keyboard_config(locale.split_locale(locale_code)[0], variant)
#     run_cmd("ACTIVE_CONSOLE=guess /bin/setupcon -k </dev/tty1")
# 
#     if save:
#         save_keyboard_settings(locale_code, variant)


from kano_settings.system.audio import set_to_HDMI
from kano_settings.boot_config import set_config_value
from kano_settings.boot_config import end_config_transaction
from kano_settings.system.overclock import set_default_overclock_values
from kano_settings.system.keyboard_config import set_keyboard
#
# default.py
#
# Copyright (C) 2014 - 2018 Kano Computing Ltd.
# License: http://www.gnu.org/licenses/gpl-2.0.txt GNU GPL v2
#
# Function to restore factory default config.
#



def set_default_config():
    # restore factory defaults

    # setting the audio to analogue
    set_to_HDMI(False)

    set_config_value('hdmi_ignore_edid_audio', 1)
    set_config_value('hdmi_drive', None)

    # resetting HDMI settings
    set_config_value('disable_overscan', 1)
    set_config_value('overscan_left', 0)
    set_config_value('overscan_right', 0)
    set_config_value('overscan_top', 0)
    set_config_value('overscan_bottom', 0)

# Path: kano_settings/system/audio.py
# def set_to_HDMI(HDMI, force=False):
#     '''
#     Set audio output to HDMI if supported by the display,
#     otherwise set it to Analogue output.
# 
#     Returns 'HDMI' or 'Analogue', whichever was applied.
#     '''
# 
#     if not is_hdmi_audio_supported() and not force:
#         HDMI = False
# 
#     # 1 analog
#     # 2 hdmi
# 
#     # These are the changes we'll apply if they have changed from what they were
#     if HDMI:
#         amixer_cmd = hdmi_cmd
#         set_config_value('hdmi_ignore_edid_audio', None)
#         set_config_value('hdmi_drive', 2)
#         config = _("HDMI")
#     else:
#         amixer_cmd = analogue_cmd
#         set_config_value('hdmi_ignore_edid_audio', 1)
#         set_config_value('hdmi_drive', None)
#         config = _("Analogue")
# 
#     end_config_transaction()
# 
#     # Set audio path in amixer
#     o, e, rc = run_cmd(amixer_cmd)
#     if rc:
#         logger.warn("error from amixer: {} {} {}".format(o, e, rc))
# 
#     # trigger alsa-store to store the path in /var/lib/alsa/asound.state
#     o, e, rc = run_cmd(store_cmd)
#     if rc:
#         logger.warn("error from alsa-store: {} {} {}".format(o, e, rc))
# 
#     set_setting('Audio', config)
#     return config
# 
# Path: kano_settings/boot_config.py
# def set_config_value(self, name, value=None, config_filter=Filter.ALL):
#     self.set_state_writable()
#     self.temp_config.set_value(name, value, config_filter)
# 
# Path: kano_settings/boot_config.py
# def end_config_transaction():
#     _trans().close()
# 
# Path: kano_settings/system/overclock.py
# def set_default_overclock_values(board_name=None):
#     board = get_board_props(board_name=board_name)
# 
#     if not board:
#         logger.error("Could not get overclocking settings for board")
#         return
# 
#     change_overclock_value(board.CLOCKING['default'], board_name)
# 
# Path: kano_settings/system/keyboard_config.py
# def set_keyboard(locale_code, variant, save=False):
#     if variant == 'generic':
#         variant = ''
# 
#     # Notify and apply changes to the XServer
#     run_cmd("setxkbmap {} {}".format(locale_code, variant))
#     set_keyboard_config(locale.split_locale(locale_code)[0], variant)
#     run_cmd("ACTIVE_CONSOLE=guess /bin/setupcon -k </dev/tty1")
# 
#     if save:
#         save_keyboard_settings(locale_code, variant)


# Path: kano_settings/default.py
from kano_settings.system.audio import set_to_HDMI
from kano_settings.boot_config import set_config_value
from kano_settings.boot_config import end_config_transaction
from kano_settings.system.overclock import set_default_overclock_values
from kano_settings.system.keyboard_config import set_keyboard

#
# default.py
#
# Copyright (C) 2014 - 2018 Kano Computing Ltd.
# License: http://www.gnu.org/licenses/gpl-2.0.txt GNU GPL v2
#
# Function to restore factory default config.
#



def set_default_config():
    # restore factory defaults

    # setting the audio to analogue
    set_to_HDMI(False)

    set_config_value('hdmi_ignore_edid_audio', 1)
    set_config_value('hdmi_drive', None)

    # resetting HDMI settings
    set_config_value('disable_overscan', 1)
    set_config_value('overscan_left', 0)
    set_config_value('overscan_right', 0)
    set_config_value('overscan_top', 0)
    set_config_value('overscan_bottom', 0)

    set_config_value('hdmi_pixel_encoding', 2)