Last active
April 27, 2025 10:05
-
-
Save VTzy137/2d7cc9acf1ba629d4319e4a7383c825f to your computer and use it in GitHub Desktop.
Script auto check and update cursor ai with app image in linux. You can manual click downloads from web, so it get that appImage from downloads and do all remaining. Link cursor AppImage to application for create app icon. paste this script info app_dir, in this is opt/cursor-ai/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# === Config === | |
APP_DIR="/opt/cursor-ai" | |
APP_FILE="$APP_DIR/AppRun" | |
APPIMAGE_FILE="$APP_DIR/Cursor.AppImage" | |
VERSION_FILE="$APP_DIR/cursor-version" | |
DESKTOP_FILE="$HOME/.local/share/applications/cursor.desktop" | |
mv ~/Downloads/Cursor* /opt/cursor-ai/ | |
LATEST_FILE=$(ls "$APP_DIR" | grep -oP 'Cursor-.*\.AppImage' | sort -V | tail -n 1) | |
if [[ -z "$LATEST_FILE" ]]; then | |
echo "β Not found downloaded cursor." | |
return 1 | |
fi | |
TMP_FILE="$APP_DIR/$LATEST_FILE" | |
LATEST_VERSION=$(echo "$LATEST_FILE" | grep -oP '[0-9]+\.[0-9]+\.[0-9]+') | |
# === Step 1: Get current version | |
if [[ -f "$VERSION_FILE" ]]; then | |
CURRENT_VERSION=$(cat "$VERSION_FILE") | |
else | |
CURRENT_VERSION="0.0.0" | |
fi | |
echo "Current installed version (recorded): $CURRENT_VERSION" | |
echo "Latest available version: $LATEST_VERSION" | |
echo "$TMP_FILE" | |
# === Step 3: Replace AppImage | |
echo "π Replacing old AppImage in $APP_DIR" | |
sudo rm -f "$APPIMAGE_FILE" | |
sudo mv "$TMP_FILE" "$APPIMAGE_FILE" | |
sudo chmod +x "$APPIMAGE_FILE" | |
# === Step 4: Update AppRun symlink | |
if [[ -f "$APP_FILE" || -L "$APP_FILE" ]]; then | |
sudo rm -f "$APP_FILE" | |
fi | |
sudo ln -s "$APPIMAGE_FILE" "$APP_FILE" | |
# === Step 5: Save version info | |
echo "$LATEST_VERSION" > "$VERSION_FILE" | |
echo "π Version $LATEST_VERSION recorded in $VERSION_FILE" | |
# === Step 6: Create .desktop entry for Rofi/system launcher | |
mkdir -p "$(dirname "$DESKTOP_FILE")" | |
cat > "$DESKTOP_FILE" <<EOF | |
[Desktop Entry] | |
Name=Cursor AI | |
Comment=AI-powered code editor | |
Exec=$APP_FILE --no-sandbox | |
Icon=$APP_DIR/usr/share/icons/hicolor/512x512/apps/cursor.png | |
Type=Application | |
Categories=Development;IDE; | |
Terminal=false | |
StartupWMClass=Cursor | |
EOF | |
update-desktop-database ~/.local/share/applications &>/dev/null || true | |
echo "π₯οΈ .desktop entry written to $DESKTOP_FILE" | |
echo "β Cursor has been updated and added to your launcher menu." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment