diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 diff --git a/reset_machine_manual.py b/reset_machine_manual.py index 45f6664..78629c6 100644 --- a/reset_machine_manual.py +++ b/reset_machine_manual.py @@ -8,6 +8,7 @@ import sqlite3 import platform import re import tempfile +import glob from colorama import Fore, Style, init from typing import Tuple import configparser @@ -49,6 +50,25 @@ 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"), "/usr/lib/cursor/app/"] } + 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")) + # Also check current directory for extraction without home path prefix + current_dir_paths = glob.glob("squashfs-root/usr/share/cursor/resources/app") + + # Add any found paths to the Linux paths list + default_paths["Linux"].extend(extracted_usr_paths) + default_paths["Linux"].extend(current_dir_paths) + + # Print debug information + 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']: @@ -181,6 +201,12 @@ def get_workbench_cursor_path(translator=None) -> str: "main": "out/vs/workbench/workbench.desktop.main.js" } } + + if system == "Linux": + # Add extracted AppImage with correct usr structure + extracted_usr_paths = glob.glob(os.path.expanduser("~/squashfs-root/usr/share/cursor/resources/app")) + + paths_map["Linux"]["bases"].extend(extracted_usr_paths) if system not in paths_map: raise OSError(translator.get('reset.unsupported_os', system=system) if translator else f"不支持的操作系统: {system}") @@ -188,9 +214,9 @@ def get_workbench_cursor_path(translator=None) -> str: if system == "Linux": for base in paths_map["Linux"]["bases"]: main_path = os.path.join(base, paths_map["Linux"]["main"]) + print(f"{Fore.CYAN}{EMOJI['INFO']} Checking path: {main_path}{Style.RESET_ALL}") if os.path.exists(main_path): return main_path - raise OSError(translator.get('reset.linux_path_not_found') if translator else "在 Linux 系统上未找到 Cursor 安装路径") if system == "Windows": base_path = config.get('WindowsPaths', 'cursor_path') 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):