Re:Void: Open-source Cursor alternative
by johnisgood on Thursday May 08, 2025 @04:00PM
(#43930683)
Not only did you mess up the formatting, but you pasted a very lengthy code, generated by an LLM. Perhaps consider using a pastebin in the future, if at all.
Edit: asked gemini2.5 to make the script for you. Copy, chmod and run. (maybe check if I am not trolling you first).
#!/bin/bash
echo "Cursor AppImage Desktop Integration Script" echo "-----------------------------------------"
# --- Configuration --- # Default application name DEFAULT_APP_NAME="Cursor" # Directory to store AppImages APPIMAGE_DIR="$HOME/Applications" # Directory for .desktop files DESKTOP_ENTRY_DIR="$HOME/.local/share/applications" # Directory for icons (optional, if you want to copy the icon) # ICON_DIR="$HOME/.local/share/icons/hicolor/scalable/apps"
# --- Ensure target directories exist --- mkdir -p "$APPIMAGE_DIR" mkdir -p "$DESKTOP_ENTRY_DIR" # mkdir -p "$ICON_DIR" # Uncomment if you choose to copy icons to a standard path
# --- Get AppImage Path --- read -e -p "Enter the full path to your Cursor AppImage file: " APPIMAGE_PATH
if [ ! -f "$APPIMAGE_PATH" ]; then echo "Error: AppImage file not found at '$APPIMAGE_PATH'." exit 1 fi
# --- Get Application Name --- read -p "Enter the name for the application menu shortcut (default: $DEFAULT_APP_NAME): " APP_NAME APP_NAME=${APP_NAME:-$DEFAULT_APP_NAME}
# Sanitize APP_NAME for use in filenames (lowercase, no spaces) DESKTOP_FILE_BASENAME=$(echo "$APP_NAME" | tr '[:upper:]' '[:lower:]' | tr -s ' ' '_' | sed 's/[^a-z0-9_-]//g') if [ -z "$DESKTOP_FILE_BASENAME" ]; then DESKTOP_FILE_BASENAME="cursorapp" # fallback fi
# --- Define Target AppImage Path --- # Use the sanitized app name or the original AppImage name for the stored file # For simplicity, let's use a generic name like AppName.AppImage TARGET_APPIMAGE_NAME="${APP_NAME}.AppImage" TARGET_APPIMAGE_PATH="$APPIMAGE_DIR/$TARGET_APPIMAGE_NAME"
# --- Move and Prepare AppImage --- echo "Copying AppImage to '$TARGET_APPIMAGE_PATH'..." cp "$APPIMAGE_PATH" "$TARGET_APPIMAGE_PATH" if [ $? -ne 0 ]; then echo "Error: Failed to copy AppImage." exit 1 fi
echo "Making AppImage executable..." chmod +x "$TARGET_APPIMAGE_PATH" if [ $? -ne 0 ]; then echo "Error: Failed to make AppImage executable." # Consider cleanup or proceed if non-critical for .desktop creation itself fi
# --- Get Icon Path (Optional) --- ICON_ENTRY="Icon=$DESKTOP_FILE_BASENAME" # Default icon name, system might find it if themed read -e -p "Enter the full path to an icon file (e.g., .png, .svg) (optional, press Enter to skip): " ICON_PATH
if [ -f "$ICON_PATH" ]; then # Option 1: Use the direct path in the .desktop file ICON_ENTRY="Icon=$ICON_PATH" echo "Using icon from '$ICON_PATH'."
elif [ ! -z "$ICON_PATH" ]; then # User entered something, but file not found echo "Warning: Icon file not found at '$ICON_PATH'. Using default icon name." fi# --- Create .desktop File --- DESKTOP_FILE_PATH="$DESKTOP_ENTRY_DIR/${DESKTOP_FILE_BASENAME}.desktop" echo "Creating .desktop file at '$DESKTOP_FILE_PATH'..."
cat > "$DESKTOP_FILE_PATH" << EOF [Desktop Entry] Version=1.0 Name=$APP_NAME Comment=AI Powered Code Editor (AppImage) Exec="$TARGET_APPIMAGE_PATH" --no-sandbox %U $ICON_ENTRY Terminal=false Type=Application Categories=Development;IDE;TextEditor;Utility; StartupWMClass=Cursor # Often helps with icon association in docks/taskbars. May need adjustment. EOF
# Try to guess StartupWMClass if possible (more advanced, requires running the app and using xprop) # For Cursor, "Cursor" is a likely candidate. If window grouping issues arise, this might need to be # identified using a tool like `xprop WM_CLASS` on an open Cursor window.
if [ $? -ne 0 ]; then echo "Error: Failed to create .desktop file." exit 1 fi
# Make .desktop file readable (and executable for user, as some guides suggest) chmod u+rwx "$DESKTOP_FILE_PATH" # User read, write, execute chmod go+r "$DESKTOP_FILE_PATH" # Group and Other read
# --- Update Desktop Database --- echo "Updating application database..." update-desktop-database -q "$DESKTOP_ENTRY_DIR" # -q for quiet
echo "" echo "-----------------------------------------" echo "Success!" echo "'$APP_NAME' should now be available in your application menu." echo "If it doesn't appear immediately, you might need to log out and log back in or restart your desktop environment." echo "" echo "To launch, you can now search for '$APP_NAME'." echo "The AppImage is stored at: $TARGET_APPIMAGE_PATH" echo "The desktop shortcut file is: $DESKTOP_FILE_PATH" echo "" echo "If you encounter issues with the icon not showing up, ensure the path in '$ICON_ENTRY' is correct or place an icon named '${DESKTOP_FILE_BASENAME}.png' (or .svg) in ~/.local/share/icons/ or a system icon theme directory." echo "-----------------------------------------"
exit 0