From a5101e7d2316ac6ffc59db2356f8cc10e41d15fc Mon Sep 17 00:00:00 2001 From: Dillon DuPont Date: Tue, 29 Jul 2025 08:19:59 -0400 Subject: [PATCH] Replaced linux typing with pynput --- .../computer-server/computer_server/handlers/linux.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/python/computer-server/computer_server/handlers/linux.py b/libs/python/computer-server/computer_server/handlers/linux.py index 6fe80a1c..5429b1a2 100644 --- a/libs/python/computer-server/computer_server/handlers/linux.py +++ b/libs/python/computer-server/computer_server/handlers/linux.py @@ -28,6 +28,9 @@ try: except Exception as e: logger.warning(f"pyautogui import failed: {str(e)}. GUI operations will be simulated.") +from pynput.mouse import Button, Controller as MouseController +from pynput.keyboard import Key, Controller as KeyboardController + from .base import BaseAccessibilityHandler, BaseAutomationHandler class LinuxAccessibilityHandler(BaseAccessibilityHandler): @@ -83,6 +86,7 @@ class LinuxAccessibilityHandler(BaseAccessibilityHandler): class LinuxAutomationHandler(BaseAutomationHandler): """Linux implementation of automation handler using pyautogui.""" + keyboard = KeyboardController() # Mouse Actions async def mouse_down(self, x: Optional[int] = None, y: Optional[int] = None, button: str = "left") -> Dict[str, Any]: @@ -189,7 +193,8 @@ class LinuxAutomationHandler(BaseAutomationHandler): async def type_text(self, text: str) -> Dict[str, Any]: try: - pyautogui.write(text) + # use pynput for Unicode support + self.keyboard.type(text) return {"success": True} except Exception as e: return {"success": False, "error": str(e)}