Skip to content

Instantly share code, notes, and snippets.

@arpagon
Last active June 28, 2024 01:00
Show Gist options
  • Save arpagon/7cb8ff6361380725c893f5535fbbb58d to your computer and use it in GitHub Desktop.
Save arpagon/7cb8ff6361380725c893f5535fbbb58d to your computer and use it in GitHub Desktop.
CursorDesktopIntegrator
#!/bin/bash
# Step 1: Find the latest version of the .AppImage
LATEST_APPIMAGE=$(ls -t $HOME/Applications/cursor-*.AppImage | head -n 1)
echo "Latest AppImage: $LATEST_APPIMAGE"
# Step 2: Update symlink to the latest version
SYMLINK_PATH="$HOME/Applications/cursor.AppImage"
ln -sf $LATEST_APPIMAGE $SYMLINK_PATH
echo "Updated symlink to: $SYMLINK_PATH"
# Step 3: Download the Cursor logo if not exists
ICON_PATH="$HOME/.local/share/icons/cursor-icon.svg"
if [ ! -f "$ICON_PATH" ]; then
mkdir -p $(dirname $ICON_PATH)
curl -o $ICON_PATH "https://mintlify.s3-us-west-1.amazonaws.com/anysphere/images/logo/app-logo.svg"
echo "Downloaded logo to: $ICON_PATH"
fi
# Step 4: Conditionally create or update the .desktop file
DESKTOP_FILE_PATH="$HOME/.local/share/applications/cursor.desktop"
if [ ! -f "$DESKTOP_FILE_PATH" ] || [ "$LATEST_APPIMAGE" != "$(grep -oP '(?<=^Exec=).*' $DESKTOP_FILE_PATH)" ]; then
DESKTOP_FILE_CONTENT="[Desktop Entry]
Name=Cursor
Exec=$SYMLINK_PATH
Terminal=false
Type=Application
Icon=$ICON_PATH
StartupWMClass=Cursor
X-AppImage-name-Version=$LATEST_APPIMAGE
Comment=Cursor is an AI-first coding environment.
MimeType=x-scheme-handler/cursor;text/markdown;
Categories=Utility;Development
"
echo "$DESKTOP_FILE_CONTENT" > $DESKTOP_FILE_PATH
chmod +x $DESKTOP_FILE_PATH
echo "Updated .desktop file at: $DESKTOP_FILE_PATH"
else
echo ".desktop file is up-to-date."
fi
@hhfrancois
Copy link

curl -o $ICON_PATH "https://www.cursor.sh/brand/icon.svg"

sh instead so

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment