#!/usr/bin/env python3

import importlib.util
import os

from fenrirscreenreader.core.i18n import _

# Load base configuration class
_base_path = os.path.join(os.path.dirname(__file__), "..", "config_base.py")
_spec = importlib.util.spec_from_file_location("config_base", _base_path)
_module = importlib.util.module_from_spec(_spec)
_spec.loader.exec_module(_module)
config_command = _module.config_command


class command(config_command):
    def __init__(self):
        super().__init__()

    def get_description(self):
        return "Set character echo to None (no character echo)"

    def run(self):
        current_mode = self.get_setting("keyboard", "charEchoMode", "1")
        
        if current_mode == "0":
            self.present_text("Character echo already set to None")
            return
        
        success = self.set_setting("keyboard", "charEchoMode", "0")
        
        if success:
            self.present_text("Character echo set to None - no typed characters will be spoken")
            self.play_sound("Accept")
        else:
            self.present_text("Failed to change character echo mode")
            self.play_sound("Error")