From f888b8c90cdcf1bdd0ad7fc8f8917019b6d5d629 Mon Sep 17 00:00:00 2001 From: Mohamed Elbanna Date: Thu, 3 Apr 2025 14:35:07 +0200 Subject: [PATCH 1/4] Enhance Linux path detection for Cursor AppImage installations --- reset_machine_manual.py | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/reset_machine_manual.py b/reset_machine_manual.py index a10f862..fd838e3 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,17 @@ 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 any AppImage mounts of Cursor + appimage_paths = glob.glob("/tmp/.mount_Cursor*/resources/app") + # Look for extracted AppImage directories + extracted_paths = glob.glob(os.path.expanduser("~/squashfs-root/resources/app")) + + # Add any found paths to the Linux paths list + default_paths["Linux"].extend(appimage_paths) + default_paths["Linux"].extend(extracted_paths) + + # If config doesn't exist, create it with default paths if not os.path.exists(config_file): for section in ['MacPaths', 'WindowsPaths', 'LinuxPaths']: @@ -174,6 +186,26 @@ def get_workbench_cursor_path(translator=None) -> str: "main": "out/vs/workbench/workbench.desktop.main.js" } } + + if system == "Linux": + # Add original AppImage paths + appimage_bases = glob.glob("/tmp/.mount_Cursor*/resources/app") + extracted_bases = glob.glob(os.path.expanduser("~/squashfs-root/resources/app")) + + # Add correct path for AppImage structure + appimage_usr_paths = glob.glob("/tmp/.mount_Cursor*/usr/share/cursor/resources/app") + + # Also try without the "app" directory if it doesn't exist + appimage_usr_resources = glob.glob("/tmp/.mount_Cursor*/usr/share/cursor/resources") + + # Add debug output + for mount in glob.glob("/tmp/.mount_Cursor*"): + print(f"{Fore.CYAN}{EMOJI['INFO']} Found AppImage mount: {mount}{Style.RESET_ALL}") + + paths_map["Linux"]["bases"].extend(appimage_bases) + paths_map["Linux"]["bases"].extend(extracted_bases) + paths_map["Linux"]["bases"].extend(appimage_usr_paths) + paths_map["Linux"]["bases"].extend(appimage_usr_resources) if system not in paths_map: raise OSError(translator.get('reset.unsupported_os', system=system) if translator else f"不支持的操作系统: {system}") @@ -181,9 +213,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 安装路径") base_path = paths_map[system]["base"] main_path = os.path.join(base_path, paths_map[system]["main"]) From 163748fd9650616adf82f1b7095aabbf4f355776 Mon Sep 17 00:00:00 2001 From: Mohamed Elbanna Date: Thu, 3 Apr 2025 14:55:56 +0200 Subject: [PATCH 2/4] Refactor Linux path detection to use extracted AppImage with correct usr structure --- build.sh | 0 reset_machine_manual.py | 22 ++++------------------ 2 files changed, 4 insertions(+), 18 deletions(-) mode change 100644 => 100755 build.sh 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 fd838e3..1db8625 100644 --- a/reset_machine_manual.py +++ b/reset_machine_manual.py @@ -188,24 +188,10 @@ def get_workbench_cursor_path(translator=None) -> str: } if system == "Linux": - # Add original AppImage paths - appimage_bases = glob.glob("/tmp/.mount_Cursor*/resources/app") - extracted_bases = glob.glob(os.path.expanduser("~/squashfs-root/resources/app")) - - # Add correct path for AppImage structure - appimage_usr_paths = glob.glob("/tmp/.mount_Cursor*/usr/share/cursor/resources/app") - - # Also try without the "app" directory if it doesn't exist - appimage_usr_resources = glob.glob("/tmp/.mount_Cursor*/usr/share/cursor/resources") - - # Add debug output - for mount in glob.glob("/tmp/.mount_Cursor*"): - print(f"{Fore.CYAN}{EMOJI['INFO']} Found AppImage mount: {mount}{Style.RESET_ALL}") - - paths_map["Linux"]["bases"].extend(appimage_bases) - paths_map["Linux"]["bases"].extend(extracted_bases) - paths_map["Linux"]["bases"].extend(appimage_usr_paths) - paths_map["Linux"]["bases"].extend(appimage_usr_resources) + # 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}") From be52ce98a61441a8f5e4fd2e8647d49e3106bb5f Mon Sep 17 00:00:00 2001 From: Mohamed Elbanna Date: Thu, 3 Apr 2025 15:20:38 +0200 Subject: [PATCH 3/4] Improve Linux cursor path detection to include extracted AppImage with correct usr structure and add debug output for found paths --- reset_machine_manual.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/reset_machine_manual.py b/reset_machine_manual.py index 1db8625..b539c65 100644 --- a/reset_machine_manual.py +++ b/reset_machine_manual.py @@ -51,14 +51,22 @@ def get_cursor_paths(translator=None) -> Tuple[str, str]: } if system == "Linux": - # Look for any AppImage mounts of Cursor - appimage_paths = glob.glob("/tmp/.mount_Cursor*/resources/app") - # Look for extracted AppImage directories - extracted_paths = glob.glob(os.path.expanduser("~/squashfs-root/resources/app")) + # 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(appimage_paths) - default_paths["Linux"].extend(extracted_paths) + 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 From edb74e21be67a45c95a9546e4b2c5fd5222453a4 Mon Sep 17 00:00:00 2001 From: Mohamed Elbanna Date: Thu, 3 Apr 2025 15:47:58 +0200 Subject: [PATCH 4/4] 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):