From edb74e21be67a45c95a9546e4b2c5fd5222453a4 Mon Sep 17 00:00:00 2001 From: Mohamed Elbanna Date: Thu, 3 Apr 2025 15:47:58 +0200 Subject: [PATCH] Enhance Linux cursor path detection to include extracted AppImage directories and add debug output for found paths --- totally_reset_cursor.py | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/totally_reset_cursor.py b/totally_reset_cursor.py index 78dcad3..5bb23b4 100644 --- a/totally_reset_cursor.py +++ b/totally_reset_cursor.py @@ -14,6 +14,7 @@ import configparser from new_signup import get_user_documents_path import traceback from config import get_config +import glob # Initialize colorama init() @@ -49,6 +50,24 @@ def get_cursor_paths(translator=None) -> Tuple[str, str]: "Linux": ["/opt/Cursor/resources/app", "/usr/share/cursor/resources/app", os.path.expanduser("~/.local/share/cursor/resources/app")] } + if system == "Linux": + # Look for extracted AppImage directories - with usr structure + extracted_usr_paths = glob.glob(os.path.expanduser("~/squashfs-root/usr/share/cursor/resources/app")) + # Check current directory for extraction without home path prefix + current_dir_paths = glob.glob("squashfs-root/usr/share/cursor/resources/app") + + # Add all paths to the Linux paths list + default_paths["Linux"].extend(extracted_usr_paths) + default_paths["Linux"].extend(current_dir_paths) + + # Print debug info for troubleshooting + print(f"{Fore.CYAN}{EMOJI['INFO']} Available paths found:{Style.RESET_ALL}") + for path in default_paths["Linux"]: + if os.path.exists(path): + print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {path} (exists){Style.RESET_ALL}") + else: + print(f"{Fore.RED}{EMOJI['ERROR']} {path} (not found){Style.RESET_ALL}") + # If config doesn't exist, create it with default paths if not os.path.exists(config_file): for section in ['MacPaths', 'WindowsPaths', 'LinuxPaths']: @@ -175,10 +194,16 @@ def get_workbench_cursor_path(translator=None) -> str: } } - if system not in paths_map: - raise OSError(translator.get('reset.unsupported_os', system=system) if translator else f"不支持的操作系统: {system}") - if system == "Linux": + # Look for extracted AppImage with correct usr structure + extracted_usr_paths = glob.glob(os.path.expanduser("~/squashfs-root/usr/share/cursor/resources/app")) + # Check current directory for extraction + current_dir_paths = glob.glob("squashfs-root/usr/share/cursor/resources/app") + + + paths_map["Linux"]["bases"].extend(extracted_usr_paths) + paths_map["Linux"]["bases"].extend(current_dir_paths) + for base in paths_map["Linux"]["bases"]: main_path = os.path.join(base, paths_map["Linux"]["main"]) if os.path.exists(main_path):