Attempt to add keyboard shortcut to switch keyboard layout.

This commit is contained in:
Storm Dragon
2025-06-04 20:17:06 -04:00
parent 7f75c231e1
commit 77065c55b4
8 changed files with 129 additions and 0 deletions

View File

@ -389,3 +389,35 @@ class inputManager():
self.lastDetectedDevices =devices
def getLastDetectedDevices(self):
return self.lastDetectedDevices
def reloadShortcuts(self):
"""Reload keyboard shortcuts from current layout setting"""
# Clear existing bindings
self.env['bindings'].clear()
self.env['rawBindings'].clear()
# Get current layout path
layout_setting = self.env['runtime']['settingsManager'].getSetting('keyboard', 'keyboardLayout')
# Resolve full path if needed
if not os.path.exists(layout_setting):
settingsRoot = '/etc/fenrirscreenreader/'
if not os.path.exists(settingsRoot):
import fenrirscreenreader
fenrirPath = os.path.dirname(fenrirscreenreader.__file__)
settingsRoot = fenrirPath + '/../../config/'
layout_path = settingsRoot + 'keyboard/' + layout_setting + '.conf'
if not os.path.exists(layout_path):
# Fallback to default if layout not found
layout_path = settingsRoot + 'keyboard/desktop.conf'
else:
layout_path = layout_setting
# Reload shortcuts
self.loadShortcuts(layout_path)
self.env['runtime']['debug'].writeDebugOut(
"Reloaded shortcuts from: " + layout_path,
debug.debugLevel.INFO,
onAnyLevel=True
)