From 0edbefac47e87d92afd83cbec71824ffd5a874ee Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Thu, 5 Jun 2025 13:11:47 -0400 Subject: [PATCH] more debugging. --- src/cthulhu/plugin_system_manager.py | 36 +++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/cthulhu/plugin_system_manager.py b/src/cthulhu/plugin_system_manager.py index bb47ff7..053fa15 100644 --- a/src/cthulhu/plugin_system_manager.py +++ b/src/cthulhu/plugin_system_manager.py @@ -159,30 +159,54 @@ class PluginSystemManager: def register_plugin_keybindings_with_active_script(self): """Register all plugin keybindings with the active script.""" + logger.info("=== register_plugin_keybindings_with_active_script() CALLED ===") + with open('/tmp/plugin_registration.log', 'a') as f: + f.write("=== register_plugin_keybindings_with_active_script() CALLED ===\n") + if not PLUGGY_AVAILABLE: + logger.warning("PLUGGY not available") + with open('/tmp/plugin_registration.log', 'a') as f: + f.write("ERROR: PLUGGY not available\n") return from . import cthulhu_state if not cthulhu_state.activeScript: logger.warning("No active script available to register plugin keybindings") + with open('/tmp/plugin_registration.log', 'a') as f: + f.write("ERROR: No active script available\n") return active_script = cthulhu_state.activeScript logger.info(f"Registering plugin keybindings with active script: {active_script}") + with open('/tmp/plugin_registration.log', 'a') as f: + f.write(f"Active script: {active_script}\n") # First, register keybindings from APIHelper's stored bindings # This is where plugin keybindings actually get stored from . import cthulhu api_helper = cthulhu.cthulhuApp.getAPIHelper() if api_helper and hasattr(api_helper, '_gestureBindings'): - logger.info("Registering stored gesture bindings from APIHelper") + logger.info("=== FOUND APIHelper with _gestureBindings ===") + with open('/tmp/plugin_registration.log', 'a') as f: + f.write("=== Registering stored gesture bindings from APIHelper ===\n") + f.write(f"Total contexts: {len(api_helper._gestureBindings)}\n") + for context_name, bindings_list in api_helper._gestureBindings.items(): logger.info(f"Processing context '{context_name}' with {len(bindings_list)} bindings") + with open('/tmp/plugin_registration.log', 'a') as f: + f.write(f"Context '{context_name}': {len(bindings_list)} bindings\n") + for binding in bindings_list: logger.info(f"Adding stored binding: {binding.keysymstring} with modifiers {binding.modifiers}") + with open('/tmp/plugin_registration.log', 'a') as f: + f.write(f" Binding: {binding.keysymstring} modifiers={binding.modifiers} desc={binding.handler.description}\n") + # Check if binding already exists to avoid duplicates if not active_script.getKeyBindings().hasKeyBinding(binding, "keysNoMask"): active_script.getKeyBindings().add(binding) + with open('/tmp/plugin_registration.log', 'a') as f: + f.write(f" ADDED to active script!\n") + # Force recalculation of keycode if it wasn't set when device was None if not binding.keycode and binding.keysymstring: from . import keybindings @@ -195,6 +219,16 @@ class PluginSystemManager: logger.warning(f"Failed to create key grab for {binding.keysymstring} - device may not be available") else: logger.info(f"Binding already exists: {binding.keysymstring}") + with open('/tmp/plugin_registration.log', 'a') as f: + f.write(f" Already exists, skipped\n") + else: + logger.warning("=== NO APIHelper or no _gestureBindings found ===") + with open('/tmp/plugin_registration.log', 'a') as f: + f.write("ERROR: No APIHelper or no _gestureBindings found!\n") + if api_helper: + f.write(f"APIHelper exists but _gestureBindings: {hasattr(api_helper, '_gestureBindings')}\n") + else: + f.write("No APIHelper found!\n") # Also check the old method for any plugins that use get_bindings() for pluginInfo in self._plugins.values():