Most of the pep8 changes finished. Be careful, things may be horribly broken.

This commit is contained in:
Storm Dragon
2025-07-03 13:22:00 -04:00
parent 7408951152
commit 21bb9c6083
344 changed files with 6374 additions and 6083 deletions

View File

@ -13,83 +13,83 @@ import configparser
from datetime import datetime
class ConfigCommand():
class config_command():
"""Base class for configuration management commands"""
def __init__(self):
self.env = None
self.settingsFile = None
self.settings_file = None
self.config = None
def initialize(self, environment):
self.env = environment
self.settingsFile = self.env['runtime']['settingsManager'].settingsFile
self.config = self.env['runtime']['settingsManager'].settings
self.settings_file = self.env['runtime']['SettingsManager'].settings_file
self.config = self.env['runtime']['SettingsManager'].settings
def shutdown(self):
pass
def setCallback(self, callback):
def set_callback(self, callback):
pass
def presentText(self, text, interrupt=True, flush=True):
def present_text(self, text, interrupt=True, flush=True):
"""Present text to user with proper speech handling"""
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
text, interrupt=interrupt, flush=flush)
def playSound(self, soundName):
def play_sound(self, soundName):
"""Play system sound"""
soundIcon = ''
sound_icon = ''
if soundName == 'Accept':
soundIcon = 'Accept'
sound_icon = 'Accept'
elif soundName == 'Error':
soundIcon = 'ErrorSound'
sound_icon = 'ErrorSound'
elif soundName == 'Cancel':
soundIcon = 'Cancel'
sound_icon = 'Cancel'
if soundIcon:
self.env['runtime']['outputManager'].presentText(
'', soundIcon=soundIcon, interrupt=False)
if sound_icon:
self.env['runtime']['OutputManager'].present_text(
'', sound_icon =sound_icon, interrupt=False)
def backupConfig(self, announce=True):
def backup_config(self, announce=True):
"""Create backup of current configuration file"""
try:
if not os.path.exists(self.settingsFile):
if not os.path.exists(self.settings_file):
message = "Configuration file not found"
if announce:
self.presentText(message)
self.present_text(message)
return False, message
# Create backup with timestamp
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
backup_path = f"{self.settingsFile}.backup_{timestamp}"
backup_path = f"{self.settings_file}.backup_{timestamp}"
shutil.copy2(self.settingsFile, backup_path)
shutil.copy2(self.settings_file, backup_path)
message = f"Configuration backed up to {backup_path}"
if announce:
self.presentText("Configuration backup created successfully")
self.present_text("Configuration backup created successfully")
return True, message
except Exception as e:
message = f"Failed to backup configuration: {str(e)}"
if announce:
self.presentText(message)
self.present_text(message)
return False, message
def reloadConfig(self):
def reload_config(self):
"""Reload configuration from file"""
try:
# Force settings manager to reload from file
self.env['runtime']['settingsManager'].loadSettings()
self.config = self.env['runtime']['settingsManager'].settings
self.env['runtime']['SettingsManager'].load_settings()
self.config = self.env['runtime']['SettingsManager'].settings
return True
except Exception as e:
self.presentText(f"Failed to reload configuration: {str(e)}")
self.present_text(f"Failed to reload configuration: {str(e)}")
return False
def findDefaultConfig(self):
def find_default_config(self):
"""Find default configuration file path"""
# Look for default config in multiple locations
default_paths = [
@ -97,12 +97,12 @@ class ConfigCommand():
'/usr/share/fenrir/settings/settings.conf',
os.path.join(
os.path.dirname(
self.settingsFile),
self.settings_file),
'settings.conf.default'),
os.path.join(
os.path.dirname(
os.path.dirname(
self.settingsFile)),
self.settings_file)),
'settings',
'settings.conf.default')]
@ -112,7 +112,7 @@ class ConfigCommand():
return None
def createBasicDefaults(self):
def create_basic_defaults(self):
"""Create basic default configuration manually"""
try:
# Create a new config with basic defaults
@ -137,10 +137,10 @@ class ConfigCommand():
self.config.set('screen', 'driver', 'vcsaDriver')
self.config.add_section('general')
self.config.set('general', 'debugMode', 'Off')
self.config.set('general', 'debug_mode', 'Off')
return True
except Exception as e:
self.presentText(f"Failed to create basic defaults: {str(e)}")
self.present_text(f"Failed to create basic defaults: {str(e)}")
return False

View File

@ -10,45 +10,45 @@ _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)
ConfigCommand = _module.ConfigCommand
config_command = _module.config_command
class command(ConfigCommand):
class command(config_command):
def __init__(self):
super().__init__()
def getDescription(self):
def get_description(self):
return "Set punctuation verbosity level"
def run(self):
currentLevel = self.getSetting('general', 'punctuationLevel', 'some')
current_level = self.get_setting('general', 'punctuationLevel', 'some')
# Present current level
levelDescriptions = {
level_descriptions = {
'none': 'None - no punctuation spoken',
'some': 'Some - basic punctuation only',
'most': 'Most - detailed punctuation',
'all': 'All - every punctuation mark'
}
currentDescription = levelDescriptions.get(currentLevel, 'Unknown')
self.presentText(f"Current punctuation level: {currentDescription}")
current_description = level_descriptions.get(current_level, 'Unknown')
self.present_text(f"Current punctuation level: {current_description}")
# Cycle through the four levels
levels = ['none', 'some', 'most', 'all']
try:
currentIndex = levels.index(currentLevel)
nextIndex = (currentIndex + 1) % len(levels)
newLevel = levels[nextIndex]
current_index = levels.index(current_level)
next_index = (current_index + 1) % len(levels)
new_level = levels[next_index]
except ValueError:
newLevel = 'some' # Default to some
new_level = 'some' # Default to some
success = self.setSetting('general', 'punctuationLevel', newLevel)
success = self.set_setting('general', 'punctuationLevel', new_level)
if success:
newDescription = levelDescriptions[newLevel]
self.presentText(f"Punctuation level set to: {newDescription}")
self.playSound('Accept')
new_description = level_descriptions[new_level]
self.present_text(f"Punctuation level set to: {new_description}")
self.play_sound('Accept')
else:
self.presentText("Failed to change punctuation level")
self.playSound('Error')
self.present_text("Failed to change punctuation level")
self.play_sound('Error')

View File

@ -10,41 +10,41 @@ _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)
ConfigCommand = _module.ConfigCommand
config_command = _module.config_command
class command(ConfigCommand):
class command(config_command):
def __init__(self):
super().__init__()
def getDescription(self):
def get_description(self):
return "Toggle debug mode"
def run(self):
currentLevel = self.getSetting('general', 'debugLevel', '0')
current_level = self.get_setting('general', 'debug_level', '0')
# Present current debug level
if currentLevel == '0':
self.presentText("Current debug mode: disabled")
newLevel = '1'
stateText = "enabled"
if current_level == '0':
self.present_text("Current debug mode: disabled")
new_level = '1'
state_text = "enabled"
else:
self.presentText(f"Current debug level: {currentLevel}")
newLevel = '0'
stateText = "disabled"
self.present_text(f"Current debug level: {current_level}")
new_level = '0'
state_text = "disabled"
success = self.setSetting('general', 'debugLevel', newLevel)
success = self.set_setting('general', 'debug_level', new_level)
if success:
self.presentText(f"Debug mode {stateText}")
if newLevel != '0':
debugMode = self.getSetting('general', 'debugMode', 'File')
if debugMode == 'File':
self.presentText(
self.present_text(f"Debug mode {state_text}")
if new_level != '0':
debug_mode = self.get_setting('general', 'debug_mode', 'File')
if debug_mode == 'File':
self.present_text(
"Debug output will be written to log file")
else:
self.presentText("Debug output will be printed to console")
self.playSound('Accept')
self.present_text("Debug output will be printed to console")
self.play_sound('Accept')
else:
self.presentText("Failed to change debug mode")
self.playSound('Error')
self.present_text("Failed to change debug mode")
self.play_sound('Error')

View File

@ -10,69 +10,69 @@ _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)
ConfigCommand = _module.ConfigCommand
config_command = _module.config_command
class command(ConfigCommand):
class command(config_command):
def __init__(self):
super().__init__()
def getDescription(self):
def get_description(self):
return "Select keyboard layout (desktop or laptop)"
def run(self):
currentLayout = self.getSetting(
current_layout = self.get_setting(
'keyboard', 'keyboardLayout', 'desktop')
# Present current layout
self.presentText(f"Current keyboard layout: {currentLayout}")
self.present_text(f"Current keyboard layout: {current_layout}")
# Find available keyboard layouts
keyboardPath = '/etc/fenrirscreenreader/keyboard'
if not os.path.isdir(keyboardPath):
keyboard_path = '/etc/fenrirscreenreader/keyboard'
if not os.path.isdir(keyboard_path):
# Development path
keyboardPath = os.path.join(
keyboard_path = os.path.join(
os.path.dirname(
self.settingsFile),
self.settings_file),
'..',
'keyboard')
availableLayouts = self.getAvailableLayouts(keyboardPath)
available_layouts = self.get_available_layouts(keyboard_path)
if len(availableLayouts) > 1:
if len(available_layouts) > 1:
# Cycle through available layouts
try:
currentIndex = availableLayouts.index(currentLayout)
nextIndex = (currentIndex + 1) % len(availableLayouts)
newLayout = availableLayouts[nextIndex]
current_index = available_layouts.index(current_layout)
next_index = (current_index + 1) % len(available_layouts)
new_layout = available_layouts[next_index]
except ValueError:
# Current layout not found, use first available
newLayout = availableLayouts[0]
new_layout = available_layouts[0]
success = self.setSetting('keyboard', 'keyboardLayout', newLayout)
success = self.set_setting('keyboard', 'keyboardLayout', new_layout)
if success:
self.presentText(f"Keyboard layout changed to: {newLayout}")
self.presentText(
self.present_text(f"Keyboard layout changed to: {new_layout}")
self.present_text(
"Please restart Fenrir for this change to take effect.")
self.playSound('Accept')
self.play_sound('Accept')
else:
self.presentText("Failed to change keyboard layout")
self.playSound('Error')
self.present_text("Failed to change keyboard layout")
self.play_sound('Error')
else:
self.presentText("Only default keyboard layout is available")
self.playSound('Cancel')
self.present_text("Only default keyboard layout is available")
self.play_sound('Cancel')
def getAvailableLayouts(self, keyboardPath):
def get_available_layouts(self, keyboard_path):
"""Find available keyboard layout files"""
layouts = []
if os.path.isdir(keyboardPath):
if os.path.isdir(keyboard_path):
try:
for file in os.listdir(keyboardPath):
for file in os.listdir(keyboard_path):
if file.endswith('.conf') and not file.startswith('.'):
layoutName = file[:-5] # Remove .conf extension
layouts.append(layoutName)
layout_name = file[:-5] # Remove .conf extension
layouts.append(layout_name)
except Exception:
pass

View File

@ -10,44 +10,44 @@ _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)
ConfigCommand = _module.ConfigCommand
config_command = _module.config_command
class command(ConfigCommand):
class command(config_command):
def __init__(self):
super().__init__()
def getDescription(self):
def get_description(self):
return "Set character echo mode"
def run(self):
currentMode = self.getSetting('keyboard', 'charEchoMode', '1')
current_mode = self.get_setting('keyboard', 'charEchoMode', '1')
# Present current mode
modeDescriptions = {
mode_descriptions = {
'0': 'None - no character echo',
'1': 'Always - echo all typed characters',
'2': 'Caps Lock - echo only when caps lock is on'
}
currentDescription = modeDescriptions.get(currentMode, 'Unknown')
self.presentText(f"Current character echo mode: {currentDescription}")
current_description = mode_descriptions.get(current_mode, 'Unknown')
self.present_text(f"Current character echo mode: {current_description}")
# Cycle through the three modes
modes = ['0', '1', '2']
try:
currentIndex = modes.index(currentMode)
nextIndex = (currentIndex + 1) % len(modes)
newMode = modes[nextIndex]
current_index = modes.index(current_mode)
next_index = (current_index + 1) % len(modes)
new_mode = modes[next_index]
except ValueError:
newMode = '1' # Default to always
new_mode = '1' # Default to always
success = self.setSetting('keyboard', 'charEchoMode', newMode)
success = self.set_setting('keyboard', 'charEchoMode', new_mode)
if success:
newDescription = modeDescriptions[newMode]
self.presentText(f"Character echo mode set to: {newDescription}")
self.playSound('Accept')
new_description = mode_descriptions[new_mode]
self.present_text(f"Character echo mode set to: {new_description}")
self.play_sound('Accept')
else:
self.presentText("Failed to change character echo mode")
self.playSound('Error')
self.present_text("Failed to change character echo mode")
self.play_sound('Error')

View File

@ -10,32 +10,32 @@ _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)
ConfigCommand = _module.ConfigCommand
config_command = _module.config_command
class command(ConfigCommand):
class command(config_command):
def __init__(self):
super().__init__()
def getDescription(self):
def get_description(self):
return "Toggle exclusive keyboard access"
def run(self):
currentState = self.getBooleanSetting('keyboard', 'grabDevices', True)
newState = self.toggleBooleanSetting('keyboard', 'grabDevices')
current_state = self.getBooleanSetting('keyboard', 'grabDevices', True)
new_state = self.toggleBooleanSetting('keyboard', 'grabDevices')
if newState != currentState:
stateText = "enabled" if newState else "disabled"
self.presentText(f"Exclusive keyboard access {stateText}")
if newState:
self.presentText(
if new_state != current_state:
state_text = "enabled" if new_state else "disabled"
self.present_text(f"Exclusive keyboard access {state_text}")
if new_state:
self.present_text(
"Fenrir will have exclusive control of keyboard input")
else:
self.presentText(
self.present_text(
"Fenrir will share keyboard input with other applications")
self.presentText(
self.present_text(
"Please restart Fenrir for this change to take effect")
self.playSound('Accept')
self.play_sound('Accept')
else:
self.presentText("Failed to change keyboard grab setting")
self.playSound('Error')
self.present_text("Failed to change keyboard grab setting")
self.play_sound('Error')

View File

@ -10,29 +10,29 @@ _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)
ConfigCommand = _module.ConfigCommand
config_command = _module.config_command
class command(ConfigCommand):
class command(config_command):
def __init__(self):
super().__init__()
def getDescription(self):
def get_description(self):
return "Toggle word echo when pressing space"
def run(self):
currentState = self.getBooleanSetting('keyboard', 'wordEcho', False)
newState = self.toggleBooleanSetting('keyboard', 'wordEcho')
current_state = self.getBooleanSetting('keyboard', 'wordEcho', False)
new_state = self.toggleBooleanSetting('keyboard', 'wordEcho')
if newState != currentState:
stateText = "enabled" if newState else "disabled"
self.presentText(f"Word echo {stateText}")
if newState:
self.presentText("Words will be spoken when you press space")
if new_state != current_state:
state_text = "enabled" if new_state else "disabled"
self.present_text(f"Word echo {state_text}")
if new_state:
self.present_text("Words will be spoken when you press space")
else:
self.presentText(
self.present_text(
"Words will not be spoken when you press space")
self.playSound('Accept')
self.play_sound('Accept')
else:
self.presentText("Failed to change word echo setting")
self.playSound('Error')
self.present_text("Failed to change word echo setting")
self.play_sound('Error')

View File

@ -10,25 +10,25 @@ _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)
ConfigCommand = _module.ConfigCommand
config_command = _module.config_command
class command(ConfigCommand):
class command(config_command):
def __init__(self):
super().__init__()
def getDescription(self):
def get_description(self):
return "Create backup of current configuration"
def run(self):
self.presentText("Creating configuration backup...")
self.present_text("Creating configuration backup...")
success, message = self.backupConfig(announce=False)
success, message = self.backup_config(announce=False)
if success:
# Force the message to be queued and spoken
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
"Configuration backup created successfully", interrupt=False, flush=False)
else:
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
"Failed to create configuration backup", interrupt=False, flush=False)

View File

@ -10,24 +10,24 @@ _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)
ConfigCommand = _module.ConfigCommand
config_command = _module.config_command
class command(ConfigCommand):
class command(config_command):
def __init__(self):
super().__init__()
def getDescription(self):
def get_description(self):
return "Reload configuration from file"
def run(self):
self.presentText("Reloading configuration from file...")
self.present_text("Reloading configuration from file...")
success = self.reloadConfig()
success = self.reload_config()
if success:
self.presentText("Configuration reloaded successfully")
self.playSound('Accept')
self.present_text("Configuration reloaded successfully")
self.play_sound('Accept')
else:
self.presentText("Failed to reload configuration")
self.playSound('Error')
self.present_text("Failed to reload configuration")
self.play_sound('Error')

View File

@ -11,65 +11,65 @@ _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)
ConfigCommand = _module.ConfigCommand
config_command = _module.config_command
class command(ConfigCommand):
class command(config_command):
def __init__(self):
super().__init__()
def getDescription(self):
def get_description(self):
return "Reset configuration to default settings"
def run(self):
self.presentText("WARNING: This will reset all settings to defaults")
self.presentText("Creating backup before reset...")
self.present_text("WARNING: This will reset all settings to defaults")
self.present_text("Creating backup before reset...")
# Create backup first
backupSuccess, backupMessage = self.backupConfig(announce=False)
backupSuccess, backupMessage = self.backup_config(announce=False)
if not backupSuccess:
self.presentText(
self.present_text(
"Failed to create backup. Reset cancelled for safety.",
interrupt=False)
self.playSound('Error')
self.play_sound('Error')
return
# Find default configuration file
defaultConfigPath = self.findDefaultConfig()
default_config_path = self.find_default_config()
if defaultConfigPath and os.path.isfile(defaultConfigPath):
if default_config_path and os.path.isfile(default_config_path):
try:
# Copy default configuration over current
shutil.copy2(defaultConfigPath, self.settingsFile)
shutil.copy2(default_config_path, self.settings_file)
# Reload the configuration
self.reloadConfig()
self.reload_config()
self.presentText(
self.present_text(
"Configuration reset to defaults successfully",
interrupt=False,
flush=False)
self.presentText(
self.present_text(
"Please restart Fenrir for all changes to take effect",
interrupt=False,
flush=False)
except Exception as e:
self.presentText(
self.present_text(
f"Failed to reset configuration: {
str(e)}", interrupt=False, flush=False)
else:
# Manually create basic default configuration
self.createBasicDefaults()
self.create_basic_defaults()
def findDefaultConfig(self):
def find_default_config(self):
"""Find the default configuration file"""
possiblePaths = [
possible_paths = [
'/usr/share/fenrirscreenreader/config/settings/settings.conf',
'/etc/fenrirscreenreader/settings/settings.conf.default',
os.path.join(
os.path.dirname(
self.settingsFile),
self.settings_file),
'settings.conf.default'),
# Development path
os.path.join(
@ -85,13 +85,13 @@ class command(ConfigCommand):
'settings.conf')
]
for path in possiblePaths:
for path in possible_paths:
if os.path.isfile(path):
return path
return None
def createBasicDefaults(self):
def create_basic_defaults(self):
"""Create basic default configuration manually"""
try:
self.config.clear()
@ -133,24 +133,24 @@ class command(ConfigCommand):
# Basic general defaults
self.config['general'] = {
'punctuationLevel': 'some',
'debugLevel': '0',
'debug_level': '0',
'numberOfClipboards': '50'
}
# Write the configuration
with open(self.settingsFile, 'w') as configfile:
with open(self.settings_file, 'w') as configfile:
self.config.write(configfile)
self.presentText(
self.present_text(
"Basic default configuration created",
interrupt=False,
flush=False)
self.presentText(
self.present_text(
"Please restart Fenrir for changes to take effect",
interrupt=False,
flush=False)
except Exception as e:
self.presentText(
self.present_text(
f"Failed to create default configuration: {
str(e)}", interrupt=False, flush=False)

View File

@ -13,50 +13,50 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return "Discard temporary changes and revert to saved settings"
def run(self):
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
"Reverting to saved configuration...", interrupt=True)
try:
# Reload settings from file, discarding runtime changes
settingsManager = self.env['runtime']['settingsManager']
settingsManager.loadSettings()
SettingsManager = self.env['runtime']['SettingsManager']
SettingsManager.load_settings()
# Reinitialize speech system with restored settings
if 'speechDriver' in self.env['runtime']:
if 'SpeechDriver' in self.env['runtime']:
try:
speechDriver = self.env['runtime']['speechDriver']
speechDriver.shutdown()
speechDriver.initialize(self.env)
SpeechDriver = self.env['runtime']['SpeechDriver']
SpeechDriver.shutdown()
SpeechDriver.initialize(self.env)
except Exception as e:
print(
f'revert_to_saved speechDriver: Error reinitializing speech driver: {
f'revert_to_saved SpeechDriver: Error reinitializing speech driver: {
str(e)}')
# Reinitialize sound system with restored settings
if 'soundDriver' in self.env['runtime']:
if 'sound_driver' in self.env['runtime']:
try:
soundDriver = self.env['runtime']['soundDriver']
soundDriver.shutdown()
soundDriver.initialize(self.env)
sound_driver = self.env['runtime']['sound_driver']
sound_driver.shutdown()
sound_driver.initialize(self.env)
except Exception as e:
print(
f'revert_to_saved soundDriver: Error reinitializing sound driver: {
f'revert_to_saved sound_driver: Error reinitializing sound driver: {
str(e)}')
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
"Successfully reverted to saved settings", interrupt=False, flush=False)
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
"All temporary changes have been discarded", interrupt=False, flush=False)
except Exception as e:
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
f"Error reverting settings: {str(e)}", interrupt=False, flush=False)
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
"You may need to restart Fenrir", interrupt=False, flush=False)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -10,30 +10,30 @@ _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)
ConfigCommand = _module.ConfigCommand
config_command = _module.config_command
class command(ConfigCommand):
class command(config_command):
def __init__(self):
super().__init__()
def getDescription(self):
def get_description(self):
return "Save current configuration to file"
def run(self):
self.presentText("Saving current configuration...")
self.present_text("Saving current configuration...")
try:
# Force reload and save of current configuration
self.reloadConfig()
self.reload_config()
# Write the configuration file
with open(self.settingsFile, 'w') as configfile:
with open(self.settings_file, 'w') as configfile:
self.config.write(configfile)
self.presentText("Configuration saved successfully")
self.playSound('Accept')
self.present_text("Configuration saved successfully")
self.play_sound('Accept')
except Exception as e:
self.presentText(f"Failed to save configuration: {str(e)}")
self.playSound('Error')
self.present_text(f"Failed to save configuration: {str(e)}")
self.play_sound('Error')

View File

@ -13,26 +13,26 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return "Save current session settings to configuration file"
def run(self):
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
"Saving current session settings to configuration file...", interrupt=True)
try:
# This calls the settings manager's save method which writes
# current runtime settings to file
self.env['runtime']['settingsManager'].saveSettings()
self.env['runtime']['SettingsManager'].save_settings()
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
"Session settings saved successfully!", interrupt=False, flush=False)
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
"All temporary changes are now permanent.", interrupt=False, flush=False)
except Exception as e:
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
f"Failed to save settings: {str(e)}", interrupt=False, flush=False)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -15,68 +15,68 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return "Show temporary changes not yet saved to file"
def run(self):
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
"Checking for unsaved changes...", interrupt=True)
try:
# Read the current config file
settingsFile = self.env['runtime']['settingsManager'].settingsFile
fileConfig = configparser.ConfigParser(interpolation=None)
fileConfig.read(settingsFile)
settings_file = self.env['runtime']['SettingsManager'].settings_file
file_config = configparser.ConfigParser(interpolation=None)
file_config.read(settings_file)
# Compare with runtime settings
runtimeSettings = self.env['runtime']['settingsManager'].settings
runtime_settings = self.env['runtime']['SettingsManager'].settings
changes = []
# Check speech settings specifically
speechSections = [
speech_sections = [
'speech',
'sound',
'keyboard',
'screen',
'general']
for section in speechSections:
if section in runtimeSettings and section in fileConfig:
for option in runtimeSettings[section]:
runtimeValue = runtimeSettings[section][option]
for section in speech_sections:
if section in runtime_settings and section in file_config:
for option in runtime_settings[section]:
runtime_value = runtime_settings[section][option]
try:
fileValue = fileConfig[section][option]
file_value = file_config[section][option]
except Exception as e:
fileValue = ""
file_value = ""
if runtimeValue != fileValue:
if runtime_value != file_value:
changes.append(
f"{section}.{option}: {fileValue}{runtimeValue}")
f"{section}.{option}: {file_value}{runtime_value}")
if changes:
self.env['runtime']['outputManager'].presentText(
f"Found {len(changes)} unsaved changes:", interrupt=True)
self.env['runtime']['OutputManager'].present_text(
f"found {len(changes)} unsaved changes:", interrupt=True)
for change in changes[:5]: # Limit to first 5 changes
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
change, interrupt=True)
if len(changes) > 5:
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
f"... and {len(changes) - 5} more changes", interrupt=True)
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
"Use save command to make these changes permanent", interrupt=True)
self.env['runtime']['outputManager'].playSound('Accept')
self.env['runtime']['OutputManager'].play_sound('Accept')
else:
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
"No unsaved changes found", interrupt=True)
self.env['runtime']['outputManager'].playSound('Cancel')
self.env['runtime']['OutputManager'].play_sound('Cancel')
except Exception as e:
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
f"Error checking for changes: {str(e)}", interrupt=True)
self.env['runtime']['outputManager'].playSound('Error')
self.env['runtime']['OutputManager'].play_sound('Error')
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -10,48 +10,48 @@ _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)
ConfigCommand = _module.ConfigCommand
config_command = _module.config_command
class command(ConfigCommand):
class command(config_command):
def __init__(self):
super().__init__()
def getDescription(self):
def get_description(self):
return "Select screen driver"
def run(self):
currentDriver = self.getSetting('screen', 'driver', 'vcsaDriver')
current_driver = self.get_setting('screen', 'driver', 'vcsaDriver')
# Present current driver
driverDescriptions = {
driver_descriptions = {
'vcsaDriver': 'VCSA Driver - Linux TTY console access',
'ptyDriver': 'PTY Driver - terminal emulation',
'dummyDriver': 'Dummy Driver - for testing only',
'debugDriver': 'Debug Driver - development/debugging'
}
currentDescription = driverDescriptions.get(
currentDriver, 'Unknown driver')
self.presentText(f"Current screen driver: {currentDescription}")
current_description = driver_descriptions.get(
current_driver, 'Unknown driver')
self.present_text(f"Current screen driver: {current_description}")
# Cycle through the available drivers
drivers = ['vcsaDriver', 'ptyDriver', 'dummyDriver', 'debugDriver']
try:
currentIndex = drivers.index(currentDriver)
nextIndex = (currentIndex + 1) % len(drivers)
newDriver = drivers[nextIndex]
current_index = drivers.index(current_driver)
next_index = (current_index + 1) % len(drivers)
new_driver = drivers[next_index]
except ValueError:
newDriver = 'vcsaDriver' # Default to VCSA
new_driver = 'vcsaDriver' # Default to VCSA
success = self.setSetting('screen', 'driver', newDriver)
success = self.set_setting('screen', 'driver', new_driver)
if success:
newDescription = driverDescriptions[newDriver]
self.presentText(f"Screen driver changed to: {newDescription}")
self.presentText(
new_description = driver_descriptions[new_driver]
self.present_text(f"Screen driver changed to: {new_description}")
self.present_text(
"Please restart Fenrir for this change to take effect.")
self.playSound('Accept')
self.play_sound('Accept')
else:
self.presentText("Failed to change screen driver")
self.playSound('Error')
self.present_text("Failed to change screen driver")
self.play_sound('Error')

View File

@ -10,41 +10,41 @@ _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)
ConfigCommand = _module.ConfigCommand
config_command = _module.config_command
class command(ConfigCommand):
class command(config_command):
def __init__(self):
super().__init__()
def getDescription(self):
def get_description(self):
return "Set screen text encoding"
def run(self):
currentEncoding = self.getSetting('screen', 'encoding', 'auto')
current_encoding = self.get_setting('screen', 'encoding', 'auto')
# Present current encoding
self.presentText(f"Current screen encoding: {currentEncoding}")
self.present_text(f"Current screen encoding: {current_encoding}")
# Cycle through available encodings
encodings = ['auto', 'utf-8', 'cp1252', 'iso-8859-1']
try:
currentIndex = encodings.index(currentEncoding)
nextIndex = (currentIndex + 1) % len(encodings)
newEncoding = encodings[nextIndex]
current_index = encodings.index(current_encoding)
next_index = (current_index + 1) % len(encodings)
new_encoding = encodings[next_index]
except ValueError:
newEncoding = 'auto' # Default to auto
new_encoding = 'auto' # Default to auto
success = self.setSetting('screen', 'encoding', newEncoding)
success = self.set_setting('screen', 'encoding', new_encoding)
if success:
self.presentText(f"Screen encoding set to: {newEncoding}")
if newEncoding == 'auto':
self.presentText(
self.present_text(f"Screen encoding set to: {new_encoding}")
if new_encoding == 'auto':
self.present_text(
"Fenrir will automatically detect text encoding")
else:
self.presentText(f"Fenrir will use {newEncoding} encoding")
self.playSound('Accept')
self.present_text(f"Fenrir will use {new_encoding} encoding")
self.play_sound('Accept')
else:
self.presentText("Failed to change screen encoding")
self.playSound('Error')
self.present_text("Failed to change screen encoding")
self.play_sound('Error')

View File

@ -10,42 +10,42 @@ _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)
ConfigCommand = _module.ConfigCommand
config_command = _module.config_command
class command(ConfigCommand):
class command(config_command):
def __init__(self):
super().__init__()
def getDescription(self):
def get_description(self):
return "Adjust sound volume"
def run(self):
currentVolume = self.getFloatSetting('sound', 'volume', 0.7)
current_volume = self.getFloatSetting('sound', 'volume', 0.7)
# Present current volume
volumePercent = int(currentVolume * 100)
self.presentText(f"Current sound volume: {volumePercent} percent")
volume_percent = int(current_volume * 100)
self.present_text(f"Current sound volume: {volume_percent} percent")
# Adjust volume by 10%
newVolume = self.adjustFloatSetting('sound', 'volume', 0.1, 0.0, 1.0)
new_volume = self.adjustFloatSetting('sound', 'volume', 0.1, 0.0, 1.0)
if newVolume != currentVolume:
newPercent = int(newVolume * 100)
self.presentText(
f"Sound volume set to {newPercent} percent",
if new_volume != current_volume:
new_percent = int(new_volume * 100)
self.present_text(
f"Sound volume set to {new_percent} percent",
interrupt=False)
self.playSound('Accept')
self.play_sound('Accept')
else:
# If we hit the maximum, try decreasing instead
newVolume = self.adjustFloatSetting(
new_volume = self.adjustFloatSetting(
'sound', 'volume', -0.1, 0.0, 1.0)
if newVolume != currentVolume:
newPercent = int(newVolume * 100)
self.presentText(
f"Sound volume set to {newPercent} percent",
if new_volume != current_volume:
new_percent = int(new_volume * 100)
self.present_text(
f"Sound volume set to {new_percent} percent",
interrupt=False)
self.playSound('Accept')
self.play_sound('Accept')
else:
self.presentText("Sound volume unchanged", interrupt=False)
self.playSound('Cancel')
self.present_text("Sound volume unchanged", interrupt=False)
self.play_sound('Cancel')

View File

@ -10,38 +10,38 @@ _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)
ConfigCommand = _module.ConfigCommand
config_command = _module.config_command
class command(ConfigCommand):
class command(config_command):
def __init__(self):
super().__init__()
def getDescription(self):
def get_description(self):
return "Select sound driver (genericDriver or gstreamerDriver)"
def run(self):
currentDriver = self.getSetting('sound', 'driver', 'genericDriver')
current_driver = self.get_setting('sound', 'driver', 'genericDriver')
# Present current driver
self.presentText(f"Current sound driver: {currentDriver}")
self.present_text(f"Current sound driver: {current_driver}")
# Toggle between the two available drivers
if currentDriver == 'genericDriver':
newDriver = 'gstreamerDriver'
driverDescription = "GStreamer Driver - advanced multimedia framework"
if current_driver == 'genericDriver':
new_driver = 'gstreamerDriver'
driver_description = "GStreamer Driver - advanced multimedia framework"
else:
newDriver = 'genericDriver'
driverDescription = "Generic Driver - uses SOX for audio playback"
new_driver = 'genericDriver'
driver_description = "Generic Driver - uses SOX for audio playback"
success = self.setSetting('sound', 'driver', newDriver)
success = self.set_setting('sound', 'driver', new_driver)
if success:
self.presentText(
f"Sound driver changed to {newDriver}. {driverDescription}")
self.presentText(
self.present_text(
f"Sound driver changed to {new_driver}. {driver_description}")
self.present_text(
"Please restart Fenrir for this change to take effect.")
self.playSound('Accept')
self.play_sound('Accept')
else:
self.presentText("Failed to change sound driver")
self.playSound('Error')
self.present_text("Failed to change sound driver")
self.play_sound('Error')

View File

@ -10,54 +10,54 @@ _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)
ConfigCommand = _module.ConfigCommand
config_command = _module.config_command
class command(ConfigCommand):
class command(config_command):
def __init__(self):
super().__init__()
def getDescription(self):
def get_description(self):
return "Select sound theme"
def run(self):
currentTheme = self.getSetting('sound', 'theme', 'default')
current_theme = self.get_setting('sound', 'theme', 'default')
# Present current theme
self.presentText(f"Current sound theme: {currentTheme}")
self.present_text(f"Current sound theme: {current_theme}")
# Look for available sound themes
soundPaths = [
sound_paths = [
'/usr/share/sounds',
'/usr/share/fenrirscreenreader/sounds',
os.path.expanduser('~/.local/share/fenrirscreenreader/sounds')
]
availableThemes = self.getAvailableThemes(soundPaths)
available_themes = self.get_available_themes(sound_paths)
if len(availableThemes) > 1:
if len(available_themes) > 1:
# For this implementation, cycle through available themes
try:
currentIndex = availableThemes.index(currentTheme)
nextIndex = (currentIndex + 1) % len(availableThemes)
newTheme = availableThemes[nextIndex]
current_index = available_themes.index(current_theme)
next_index = (current_index + 1) % len(available_themes)
new_theme = available_themes[next_index]
except ValueError:
# Current theme not found in available themes, use first one
newTheme = availableThemes[0]
new_theme = available_themes[0]
success = self.setSetting('sound', 'theme', newTheme)
success = self.set_setting('sound', 'theme', new_theme)
if success:
self.presentText(f"Sound theme changed to: {newTheme}")
self.playSound('Accept')
self.present_text(f"Sound theme changed to: {new_theme}")
self.play_sound('Accept')
else:
self.presentText("Failed to change sound theme")
self.playSound('Error')
self.present_text("Failed to change sound theme")
self.play_sound('Error')
else:
self.presentText("Only default sound theme is available")
self.playSound('Cancel')
self.present_text("Only default sound theme is available")
self.play_sound('Cancel')
def getAvailableThemes(self, searchPaths):
def get_available_themes(self, searchPaths):
"""Find available sound themes in the search paths"""
themes = ['default'] # Always include default
@ -65,24 +65,24 @@ class command(ConfigCommand):
if os.path.isdir(path):
try:
for item in os.listdir(path):
fullPath = os.path.join(path, item)
full_path = os.path.join(path, item)
if os.path.isdir(
fullPath) and item != 'default' and item not in themes:
full_path) and item != 'default' and item not in themes:
# Check if it looks like a sound theme (contains
# sound files)
if self.isValidSoundTheme(fullPath):
if self.is_valid_sound_theme(full_path):
themes.append(item)
except Exception:
continue
return themes
def isValidSoundTheme(self, themePath):
def is_valid_sound_theme(self, themePath):
"""Check if a directory contains sound files"""
soundExtensions = ['.wav', '.ogg', '.mp3', '.flac']
sound_extensions = ['.wav', '.ogg', '.mp3', '.flac']
try:
for file in os.listdir(themePath):
if any(file.lower().endswith(ext) for ext in soundExtensions):
if any(file.lower().endswith(ext) for ext in sound_extensions):
return True
except Exception:
pass

View File

@ -10,25 +10,25 @@ _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)
ConfigCommand = _module.ConfigCommand
config_command = _module.config_command
class command(ConfigCommand):
class command(config_command):
def __init__(self):
super().__init__()
def getDescription(self):
def get_description(self):
return "Toggle sound output on or off"
def run(self):
currentState = self.getBooleanSetting('sound', 'enabled', True)
newState = self.toggleBooleanSetting('sound', 'enabled')
current_state = self.getBooleanSetting('sound', 'enabled', True)
new_state = self.toggleBooleanSetting('sound', 'enabled')
if newState != currentState:
stateText = "enabled" if newState else "disabled"
self.presentText(f"Sound {stateText}")
if new_state != current_state:
state_text = "enabled" if new_state else "disabled"
self.present_text(f"Sound {state_text}")
# Only play sound if we enabled sound
if newState:
self.playSound('Accept')
if new_state:
self.play_sound('Accept')
else:
self.presentText("Failed to change sound setting")
self.present_text("Failed to change sound setting")

View File

@ -13,36 +13,36 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return "Adjust speech pitch (voice height)"
def run(self):
try:
# Get current pitch
currentPitch = float(
self.env['runtime']['settingsManager'].getSetting(
current_pitch = float(
self.env['runtime']['SettingsManager'].get_setting(
'speech', 'pitch'))
except Exception as e:
currentPitch = 0.5
current_pitch = 0.5
# Present current pitch
pitchPercent = int(currentPitch * 100)
self.env['runtime']['outputManager'].presentText(
f"Current speech pitch: {pitchPercent} percent", interrupt=True)
pitch_percent = int(current_pitch * 100)
self.env['runtime']['OutputManager'].present_text(
f"Current speech pitch: {pitch_percent} percent", interrupt=True)
# Increase by 10%, wrap around if at max
newPitch = currentPitch + 0.1
if newPitch > 1.0:
newPitch = 0.1 # Wrap to minimum
new_pitch = current_pitch + 0.1
if new_pitch > 1.0:
new_pitch = 0.1 # Wrap to minimum
# Apply the new pitch
self.env['runtime']['settingsManager'].setSetting(
'speech', 'pitch', str(newPitch))
self.env['runtime']['SettingsManager'].set_setting(
'speech', 'pitch', str(new_pitch))
newPercent = int(newPitch * 100)
self.env['runtime']['outputManager'].presentText(
f"Speech pitch set to {newPercent} percent", interrupt=True)
self.env['runtime']['outputManager'].playSound('Accept')
new_percent = int(new_pitch * 100)
self.env['runtime']['OutputManager'].present_text(
f"Speech pitch set to {new_percent} percent", interrupt=True)
self.env['runtime']['OutputManager'].play_sound('Accept')
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -13,35 +13,35 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return "Adjust speech rate (speed)"
def run(self):
try:
# Get current rate
currentRate = float(
self.env['runtime']['settingsManager'].getSetting(
current_rate = float(
self.env['runtime']['SettingsManager'].get_setting(
'speech', 'rate'))
except Exception as e:
currentRate = 0.5
current_rate = 0.5
# Present current rate
ratePercent = int(currentRate * 100)
self.env['runtime']['outputManager'].presentText(
f"Current speech rate: {ratePercent} percent", interrupt=True)
rate_percent = int(current_rate * 100)
self.env['runtime']['OutputManager'].present_text(
f"Current speech rate: {rate_percent} percent", interrupt=True)
# Increase by 10%, wrap around if at max
newRate = currentRate + 0.1
if newRate > 1.0:
newRate = 0.1 # Wrap to minimum
new_rate = current_rate + 0.1
if new_rate > 1.0:
new_rate = 0.1 # Wrap to minimum
# Apply the new rate
self.env['runtime']['settingsManager'].setSetting(
'speech', 'rate', str(newRate))
self.env['runtime']['SettingsManager'].set_setting(
'speech', 'rate', str(new_rate))
newPercent = int(newRate * 100)
self.env['runtime']['outputManager'].presentText(
f"Speech rate set to {newPercent} percent", interrupt=False, flush=False)
new_percent = int(new_rate * 100)
self.env['runtime']['OutputManager'].present_text(
f"Speech rate set to {new_percent} percent", interrupt=False, flush=False)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -13,47 +13,47 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return "Adjust speech rate (temporary - use save to make permanent)"
def run(self):
try:
# Get current rate from runtime settings (may be temporary)
settingsManager = self.env['runtime']['settingsManager']
currentRate = float(settingsManager.getSetting('speech', 'rate'))
SettingsManager = self.env['runtime']['SettingsManager']
current_rate = float(SettingsManager.get_setting('speech', 'rate'))
except Exception as e:
currentRate = 0.5
current_rate = 0.5
# Present current rate
ratePercent = int(currentRate * 100)
self.env['runtime']['outputManager'].presentText(
f"Current speech rate: {ratePercent} percent", interrupt=True)
rate_percent = int(current_rate * 100)
self.env['runtime']['OutputManager'].present_text(
f"Current speech rate: {rate_percent} percent", interrupt=True)
# Increase by 10%, wrap around if at max
newRate = currentRate + 0.1
if newRate > 1.0:
newRate = 0.1 # Wrap to minimum
new_rate = current_rate + 0.1
if new_rate > 1.0:
new_rate = 0.1 # Wrap to minimum
# Apply ONLY to runtime - this is temporary until saved
settingsManager = self.env['runtime']['settingsManager']
settingsManager.settings['speech']['rate'] = str(newRate)
SettingsManager = self.env['runtime']['SettingsManager']
SettingsManager.settings['speech']['rate'] = str(new_rate)
# Apply to speech system immediately for this session
if 'speechDriver' in self.env['runtime']:
if 'SpeechDriver' in self.env['runtime']:
try:
self.env['runtime']['speechDriver'].setRate(newRate)
self.env['runtime']['SpeechDriver'].set_rate(new_rate)
except Exception as e:
print(
f'adjust_speech_rate setRate: Error setting speech rate: {
f'adjust_speech_rate set_rate: Error setting speech rate: {
str(e)}')
newPercent = int(newRate * 100)
self.env['runtime']['outputManager'].presentText(
f"Speech rate temporarily set to {newPercent} percent",
new_percent = int(new_rate * 100)
self.env['runtime']['OutputManager'].present_text(
f"Speech rate temporarily set to {new_percent} percent",
interrupt=False,
flush=False)
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
"Use save command to make permanent", interrupt=False, flush=False)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -13,36 +13,36 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return "Adjust speech volume (loudness)"
def run(self):
try:
# Get current volume
currentVolume = float(
self.env['runtime']['settingsManager'].getSetting(
current_volume = float(
self.env['runtime']['SettingsManager'].get_setting(
'speech', 'volume'))
except Exception as e:
currentVolume = 1.0
current_volume = 1.0
# Present current volume
volumePercent = int(currentVolume * 100)
self.env['runtime']['outputManager'].presentText(
f"Current speech volume: {volumePercent} percent", interrupt=True)
volume_percent = int(current_volume * 100)
self.env['runtime']['OutputManager'].present_text(
f"Current speech volume: {volume_percent} percent", interrupt=True)
# Increase by 10%, wrap around if at max
newVolume = currentVolume + 0.1
if newVolume > 1.0:
newVolume = 0.1 # Wrap to minimum
new_volume = current_volume + 0.1
if new_volume > 1.0:
new_volume = 0.1 # Wrap to minimum
# Apply the new volume
self.env['runtime']['settingsManager'].setSetting(
'speech', 'volume', str(newVolume))
self.env['runtime']['SettingsManager'].set_setting(
'speech', 'volume', str(new_volume))
newPercent = int(newVolume * 100)
self.env['runtime']['outputManager'].presentText(
f"Speech volume set to {newPercent} percent", interrupt=True)
self.env['runtime']['outputManager'].playSound('Accept')
new_percent = int(new_volume * 100)
self.env['runtime']['OutputManager'].present_text(
f"Speech volume set to {new_percent} percent", interrupt=True)
self.env['runtime']['OutputManager'].play_sound('Accept')
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -13,68 +13,68 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return "Show current speech settings"
def run(self):
# Get current speech settings
driver = self.env['runtime']['settingsManager'].getSetting(
driver = self.env['runtime']['SettingsManager'].get_setting(
'speech', 'driver')
module = self.env['runtime']['settingsManager'].getSetting(
module = self.env['runtime']['SettingsManager'].get_setting(
'speech', 'module')
voice = self.env['runtime']['settingsManager'].getSetting(
voice = self.env['runtime']['SettingsManager'].get_setting(
'speech', 'voice')
rate = self.env['runtime']['settingsManager'].getSetting(
rate = self.env['runtime']['SettingsManager'].get_setting(
'speech', 'rate')
pitch = self.env['runtime']['settingsManager'].getSetting(
pitch = self.env['runtime']['SettingsManager'].get_setting(
'speech', 'pitch')
volume = self.env['runtime']['settingsManager'].getSetting(
volume = self.env['runtime']['SettingsManager'].get_setting(
'speech', 'volume')
enabled = self.env['runtime']['settingsManager'].getSetting(
enabled = self.env['runtime']['SettingsManager'].get_setting(
'speech', 'enabled')
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
"Current speech settings:", interrupt=True)
# Present all settings
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
f"Speech enabled: {enabled}", interrupt=True)
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
f"Driver: {driver}", interrupt=True)
if module:
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
f"Module: {module}", interrupt=True)
if voice:
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
f"Voice: {voice}", interrupt=True)
try:
ratePercent = int(float(rate) * 100)
self.env['runtime']['outputManager'].presentText(
f"Rate: {ratePercent} percent", interrupt=True)
rate_percent = int(float(rate) * 100)
self.env['runtime']['OutputManager'].present_text(
f"Rate: {rate_percent} percent", interrupt=True)
except Exception as e:
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
f"Rate: {rate}", interrupt=True)
try:
pitchPercent = int(float(pitch) * 100)
self.env['runtime']['outputManager'].presentText(
f"Pitch: {pitchPercent} percent", interrupt=True)
pitch_percent = int(float(pitch) * 100)
self.env['runtime']['OutputManager'].present_text(
f"Pitch: {pitch_percent} percent", interrupt=True)
except Exception as e:
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
f"Pitch: {pitch}", interrupt=True)
try:
volumePercent = int(float(volume) * 100)
self.env['runtime']['outputManager'].presentText(
f"Volume: {volumePercent} percent", interrupt=True)
volume_percent = int(float(volume) * 100)
self.env['runtime']['OutputManager'].present_text(
f"Volume: {volume_percent} percent", interrupt=True)
except Exception as e:
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
f"Volume: {volume}", interrupt=True)
self.env['runtime']['outputManager'].playSound('Accept')
self.env['runtime']['OutputManager'].play_sound('Accept')
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -18,12 +18,12 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return 'No description found'
def run(self):
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
'ok i run open macro', interrupt=True)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -18,12 +18,12 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return 'No description found'
def run(self):
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
'ok i run open save', interrupt=True)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -18,12 +18,12 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return 'No description found'
def run(self):
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
'ok i run replace macro', interrupt=True)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -18,12 +18,12 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return 'No description found'
def run(self):
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
'ok i run search macro', interrupt=True)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -19,21 +19,21 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return _('presents the date')
def run(self):
dateFormat = self.env['runtime']['settingsManager'].getSetting(
'general', 'dateFormat')
date_format = self.env['runtime']['SettingsManager'].get_setting(
'general', 'date_format')
# get the time formatted
dateString = datetime.datetime.strftime(
datetime.datetime.now(), dateFormat)
date_string = datetime.datetime.strftime(
datetime.datetime.now(), date_format)
# present the time via speak and braile, there is no soundicon,
# interrupt the current speech
self.env['runtime']['outputManager'].presentText(
dateString, soundIcon='', interrupt=True)
self.env['runtime']['OutputManager'].present_text(
date_string, sound_icon ='', interrupt=True)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -14,17 +14,17 @@ class command():
def initialize(self, environment):
self.env = environment
self.keyMakro = [[1, 'KEY_LEFTCTRL'], [1, 'KEY_G'], [
self.key_macro = [[1, 'KEY_LEFTCTRL'], [1, 'KEY_G'], [
0.05, 'sleep'], [0, 'KEY_G'], [0, 'KEY_LEFTCTRL']]
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return 'No description found'
def run(self):
self.env['runtime']['inputManager'].sendKeys(self.keyMakro)
self.env['runtime']['InputManager'].send_keys(self.key_macro)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -27,11 +27,11 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return 'No description found'
def run(self):
self.env['runtime']['inputManager'].sendKeys(self.macro)
self.env['runtime']['InputManager'].send_keys(self.macro)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -18,12 +18,12 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return 'No description found'
def run(self):
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
'ok i run open save', interrupt=True)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -18,12 +18,12 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return 'No description found'
def run(self):
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
'ok i run replace macro', interrupt=True)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -18,12 +18,12 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return 'No description found'
def run(self):
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
'ok i run search macro', interrupt=True)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -19,21 +19,21 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return _('presents the date')
def run(self):
dateFormat = self.env['runtime']['settingsManager'].getSetting(
'general', 'dateFormat')
date_format = self.env['runtime']['SettingsManager'].get_setting(
'general', 'date_format')
# get the time formatted
dateString = datetime.datetime.strftime(
datetime.datetime.now(), dateFormat)
date_string = datetime.datetime.strftime(
datetime.datetime.now(), date_format)
# present the time via speak and braile, there is no soundicon,
# interrupt the current speech
self.env['runtime']['outputManager'].presentText(
dateString, soundIcon='', interrupt=True)
self.env['runtime']['OutputManager'].present_text(
date_string, sound_icon ='', interrupt=True)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -11,7 +11,7 @@ class command():
def initialize(self, environment):
self.env = environment
self.keyMakro = [[1, 'KEY_LEFTCTRL'],
self.key_macro = [[1, 'KEY_LEFTCTRL'],
[1, 'KEY_G'],
[0.05, 'SLEEP'],
[0, 'KEY_G'],
@ -20,16 +20,16 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return "Learn about the Nano text editor."
def run(self):
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
"Okay, loading the information about Nano.", interrupt=True)
if self.env['runtime']['inputManager'].getShortcutType() in ['KEY']:
self.env['runtime']['inputManager'].sendKeys(self.keyMakro)
elif self.env['runtime']['inputManager'].getShortcutType() in ['BYTE']:
self.env['runtime']['byteManager'].sendBytes(self.byteMakro)
if self.env['runtime']['InputManager'].get_shortcut_type() in ['KEY']:
self.env['runtime']['InputManager'].send_keys(self.key_macro)
elif self.env['runtime']['InputManager'].get_shortcut_type() in ['BYTE']:
self.env['runtime']['ByteManager'].send_bytes(self.byteMakro)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -18,12 +18,12 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return 'No description found'
def run(self):
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
'ok i run open macro', interrupt=True)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -11,7 +11,7 @@ class command():
def initialize(self, environment):
self.env = environment
self.keyMakro = [[1, 'KEY_LEFTCTRL'],
self.key_macro = [[1, 'KEY_LEFTCTRL'],
[1, 'KEY_S'],
[0.05, 'SLEEP'],
[0, 'KEY_S'],
@ -20,16 +20,16 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return "Save your work."
def run(self):
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
"Okay, you will now be asked to save your work.", interrupt=True)
if self.env['runtime']['inputManager'].getShortcutType() in ['KEY']:
self.env['runtime']['inputManager'].sendKeys(self.keyMakro)
elif self.env['runtime']['inputManager'].getShortcutType() in ['BYTE']:
self.env['runtime']['byteManager'].sendBytes(self.byteMakro)
if self.env['runtime']['InputManager'].get_shortcut_type() in ['KEY']:
self.env['runtime']['InputManager'].send_keys(self.key_macro)
elif self.env['runtime']['InputManager'].get_shortcut_type() in ['BYTE']:
self.env['runtime']['ByteManager'].send_bytes(self.byteMakro)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -18,12 +18,12 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return 'No description found'
def run(self):
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
'ok i run replace macro', interrupt=True)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -18,12 +18,12 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return 'No description found'
def run(self):
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
'ok i run search macro', interrupt=True)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -19,21 +19,21 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return _('presents the date')
def run(self):
dateFormat = self.env['runtime']['settingsManager'].getSetting(
'general', 'dateFormat')
date_format = self.env['runtime']['SettingsManager'].get_setting(
'general', 'date_format')
# get the time formatted
dateString = datetime.datetime.strftime(
datetime.datetime.now(), dateFormat)
date_string = datetime.datetime.strftime(
datetime.datetime.now(), date_format)
# present the time via speak and braile, there is no soundicon,
# interrupt the current speech
self.env['runtime']['outputManager'].presentText(
dateString, soundIcon='', interrupt=True)
self.env['runtime']['OutputManager'].present_text(
date_string, sound_icon ='', interrupt=True)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -18,12 +18,12 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return 'No description found'
def run(self):
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
'ok i run open macro', interrupt=True)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -18,12 +18,12 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return 'No description found'
def run(self):
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
'ok i run open save', interrupt=True)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -18,12 +18,12 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return 'No description found'
def run(self):
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
'ok i run replace macro', interrupt=True)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -18,12 +18,12 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return 'No description found'
def run(self):
self.env['runtime']['outputManager'].presentText(
self.env['runtime']['OutputManager'].present_text(
'ok i run search macro', interrupt=True)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -19,21 +19,21 @@ class command():
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return _('presents the date')
def run(self):
dateFormat = self.env['runtime']['settingsManager'].getSetting(
'general', 'dateFormat')
date_format = self.env['runtime']['SettingsManager'].get_setting(
'general', 'date_format')
# get the time formatted
dateString = datetime.datetime.strftime(
datetime.datetime.now(), dateFormat)
date_string = datetime.datetime.strftime(
datetime.datetime.now(), date_format)
# present the time via speak and braile, there is no soundicon,
# interrupt the current speech
self.env['runtime']['outputManager'].presentText(
dateString, soundIcon='', interrupt=True)
self.env['runtime']['OutputManager'].present_text(
date_string, sound_icon ='', interrupt=True)
def setCallback(self, callback):
def set_callback(self, callback):
pass

View File

@ -15,22 +15,22 @@ class command():
def initialize(self, environment):
self.env = environment
# examples:
# self.keyMakro = [[1,'KEY_LEFTCTRL'],[1,'KEY_O'],[0.05,'SLEEP'],[0,'KEY_O'],[0,'KEY_LEFTCTRL']]
# self.keyMakro = [[1,'KEY_LEFTSHIFT'],[1,'KEY_LEFTCTRL'],[1,'KEY_N'],[0.05,'SLEEP'],[0,'KEY_N'],[0,'KEY_LEFTCTRL'],[0,'KEY_LEFTSHIFT']]
self.keyMakro = []
# self.key_macro = [[1,'KEY_LEFTCTRL'],[1,'KEY_O'],[0.05,'SLEEP'],[0,'KEY_O'],[0,'KEY_LEFTCTRL']]
# self.key_macro = [[1,'KEY_LEFTSHIFT'],[1,'KEY_LEFTCTRL'],[1,'KEY_N'],[0.05,'SLEEP'],[0,'KEY_N'],[0,'KEY_LEFTCTRL'],[0,'KEY_LEFTSHIFT']]
self.key_macro = []
self.byteMakro = []
def shutdown(self):
pass
def getDescription(self):
def get_description(self):
return 'No description found'
def run(self):
if self.env['runtime']['inputManager'].getShortcutType() in ['KEY']:
self.env['runtime']['inputManager'].sendKeys(self.keyMakro)
elif self.env['runtime']['inputManager'].getShortcutType() in ['BYTE']:
self.env['runtime']['byteManager'].sendBytes(self.byteMakro)
if self.env['runtime']['InputManager'].get_shortcut_type() in ['KEY']:
self.env['runtime']['InputManager'].send_keys(self.key_macro)
elif self.env['runtime']['InputManager'].get_shortcut_type() in ['BYTE']:
self.env['runtime']['ByteManager'].send_bytes(self.byteMakro)
def setCallback(self, callback):
def set_callback(self, callback):
pass