Fixed user reported bug. Turns out old debugging was still in place. Should be fixed now.
This commit is contained in:
@@ -26,6 +26,7 @@ import select
|
||||
import logging
|
||||
import threading
|
||||
from threading import Thread, Lock
|
||||
from typing import Optional
|
||||
from cthulhu.plugin import Plugin, cthulhu_hookimpl
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -34,6 +35,13 @@ logger = logging.getLogger(__name__)
|
||||
APPEND_CODE = '<#APPEND#>'
|
||||
PERSISTENT_CODE = '<#PERSISTENT#>'
|
||||
|
||||
def _get_socket_file() -> Optional[str]:
|
||||
runtimeDir = os.environ.get('XDG_RUNTIME_DIR')
|
||||
if not runtimeDir:
|
||||
return None
|
||||
|
||||
return os.path.join(runtimeDir, 'cthulhu.sock')
|
||||
|
||||
class SelfVoice(Plugin):
|
||||
"""Plugin that provides a socket interface for external applications to send text to Cthulhu."""
|
||||
|
||||
@@ -115,10 +123,11 @@ class SelfVoice(Plugin):
|
||||
|
||||
def voiceWorker(self):
|
||||
"""Worker thread that listens on a socket for messages to speak."""
|
||||
socketFile = '/tmp/cthulhu.sock'
|
||||
# For testing purposes
|
||||
# socketFile = '/tmp/cthulhu-plugin.sock'
|
||||
|
||||
socketFile = _get_socket_file()
|
||||
if not socketFile:
|
||||
logger.error("XDG_RUNTIME_DIR is not set; Self Voice plugin cannot create its socket")
|
||||
return
|
||||
|
||||
# Clean up any existing socket file
|
||||
if os.path.exists(socketFile):
|
||||
try:
|
||||
|
||||
@@ -393,8 +393,6 @@ class Script(script.Script):
|
||||
return keyBindings
|
||||
|
||||
def getExtensionBindings(self):
|
||||
with open('/tmp/extension_bindings_debug.log', 'a') as f:
|
||||
f.write(f"=== getExtensionBindings() called ===\n")
|
||||
keyBindings = keybindings.KeyBindings()
|
||||
|
||||
bindings = self.notificationPresenter.get_bindings()
|
||||
@@ -443,35 +441,13 @@ class Script(script.Script):
|
||||
try:
|
||||
if hasattr(cthulhu, 'cthulhuApp') and cthulhu.cthulhuApp:
|
||||
api_helper = cthulhu.cthulhuApp.getAPIHelper()
|
||||
with open('/tmp/extension_bindings_debug.log', 'a') as f:
|
||||
f.write(f"=== Checking for plugin bindings ===\n")
|
||||
f.write(f"api_helper exists: {api_helper is not None}\n")
|
||||
if api_helper:
|
||||
f.write(f"api_helper has _gestureBindings: {hasattr(api_helper, '_gestureBindings')}\n")
|
||||
if hasattr(api_helper, '_gestureBindings'):
|
||||
f.write(f"_gestureBindings content: {api_helper._gestureBindings}\n")
|
||||
f.write(f"Available contexts: {list(api_helper._gestureBindings.keys())}\n")
|
||||
|
||||
if api_helper and hasattr(api_helper, '_gestureBindings'):
|
||||
with open('/tmp/extension_bindings_debug.log', 'a') as f:
|
||||
f.write(f"=== Adding plugin bindings in getExtensionBindings() ===\n")
|
||||
|
||||
for context_name, context_bindings in api_helper._gestureBindings.items():
|
||||
for binding in context_bindings:
|
||||
keyBindings.add(binding)
|
||||
with open('/tmp/extension_bindings_debug.log', 'a') as f:
|
||||
f.write(f"Added plugin binding: {binding.keysymstring} modifiers={binding.modifiers} desc={binding.handler.description}\n")
|
||||
else:
|
||||
with open('/tmp/extension_bindings_debug.log', 'a') as f:
|
||||
f.write(f"=== No plugin bindings available ===\n")
|
||||
else:
|
||||
with open('/tmp/extension_bindings_debug.log', 'a') as f:
|
||||
f.write(f"=== cthulhuApp not available ===\n")
|
||||
except Exception as e:
|
||||
import cthulhu.debug as debug
|
||||
debug.printMessage(debug.LEVEL_WARNING, f"Failed to add plugin bindings: {e}", True)
|
||||
with open('/tmp/extension_bindings_debug.log', 'a') as f:
|
||||
f.write(f"Exception in plugin binding addition: {e}\n")
|
||||
|
||||
return keyBindings
|
||||
|
||||
|
||||
Reference in New Issue
Block a user