# Path: kano_settings/config_file.py
# def get_setting(variable):
# 
#     try:
#         value = read_json(settings_file)[variable]
#     except Exception:
#         if variable not in DEFAULTS:
#             logger.info("Defaults not found for variable: {}".format(variable))
#         value = DEFAULTS[variable]
#     return value
# 
# def set_setting(variable, value):
# 
#     if username == 'root':
#         return
# 
#     logger.debug(u"config_file / set_setting: {} {}".format(variable, value))
# 
#     data = read_json(settings_file)
#     if not data:
#         data = dict()
# 
#     data[variable] = value
#     write_json(settings_file, data)
#     chown_path(settings_file)
# 
# 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)
# 
# def end_config_transaction():
#     _trans().close()
# 
# Path: kano_settings/paths.py
# ASOUND_CONF_PATH = join(ASOUND_CONF_BASE_PATH, ASOUND_CONF_NAME)


from kano.utils.shell import run_cmd, run_bg
from kano.logging import logger
from kano_peripherals.wrappers.detection import is_pi_hat_plugged
from kano_settings.config_file import get_setting, set_setting
from kano_settings.boot_config import set_config_value, end_config_transaction
from kano_settings.paths import ASOUND_CONF_PATH
        from kano_settings.system.display import get_edid
        so there's no generalisation done here.

    Args:
        decibel - float number for the value of max_dB to set

    Returns:
        bool whether or not any changes were made to the config file
    """
    changes = False

    with open(ASOUND_CONF_PATH, 'r') as asound_conf:
        asound_conf_lines = asound_conf.readlines()

    for index, line in enumerate(asound_conf_lines):

        # Check if the setting is already the one we need.
        if line.strip().startswith('max_dB'):
            if line.strip() != 'max_dB {0:0.1f}'.format(decibel):

                asound_conf_lines[index] = '{0} {1:0.1f}\n'.format(
                    # Grab the line with the required indent, e.g. '    max_dB'
                    line.rstrip().rsplit(' ', 1)[0],
                    decibel
                )
                changes = True
                break

    if not changes:
        return False


# Path: kano_settings/config_file.py
# def get_setting(variable):
# 
#     try:
#         value = read_json(settings_file)[variable]
#     except Exception:
#         if variable not in DEFAULTS:
#             logger.info("Defaults not found for variable: {}".format(variable))
#         value = DEFAULTS[variable]
#     return value
# 
# def set_setting(variable, value):
# 
#     if username == 'root':
#         return
# 
#     logger.debug(u"config_file / set_setting: {} {}".format(variable, value))
# 
#     data = read_json(settings_file)
#     if not data:
#         data = dict()
# 
#     data[variable] = value
#     write_json(settings_file, data)
#     chown_path(settings_file)
# 
# 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)
# 
# def end_config_transaction():
#     _trans().close()
# 
# Path: kano_settings/paths.py
# ASOUND_CONF_PATH = join(ASOUND_CONF_BASE_PATH, ASOUND_CONF_NAME)


# Path: kano_settings/system/audio.py
from kano.utils.shell import run_cmd, run_bg
from kano.logging import logger
from kano_peripherals.wrappers.detection import is_pi_hat_plugged
from kano_settings.config_file import get_setting, set_setting
from kano_settings.boot_config import set_config_value, end_config_transaction
from kano_settings.paths import ASOUND_CONF_PATH
        from kano_settings.system.display import get_edid

        so there's no generalisation done here.

    Args:
        decibel - float number for the value of max_dB to set

    Returns:
        bool whether or not any changes were made to the config file
    """
    changes = False

    with open(ASOUND_CONF_PATH, 'r') as asound_conf:
        asound_conf_lines = asound_conf.readlines()

    for index, line in enumerate(asound_conf_lines):

        # Check if the setting is already the one we need.
        if line.strip().startswith('max_dB'):
            if line.strip() != 'max_dB {0:0.1f}'.format(decibel):

                asound_conf_lines[index] = '{0} {1:0.1f}\n'.format(
                    # Grab the line with the required indent, e.g. '    max_dB'
                    line.rstrip().rsplit(' ', 1)[0],
                    decibel
                )
                changes = True
                break

    if not changes:
        return False


    with open(ASOUND_CONF_PATH, 'w') as asound_conf: