cursor icon indicating copy to clipboard operation
cursor copied to clipboard

Bash Script for Cursor App Desktop Integration on Linux Environments

Open arpagon opened this issue 2 years ago • 9 comments

Feature Request for Cursor App Desktop Integration on Linux

Is your feature request related to a problem? Please describe.

Yes, integrating the Cursor app into Linux desktop environments is a manual process. I'm always frustrated when I download a new .AppImage version and have to update the .desktop file and the icon manually.

Describe the solution you'd like

I've created a bash script that automates the entire process. It does the following:

  1. Finds the latest version of the Cursor .AppImage.
  2. Updates or creates a symlink to point to the latest .AppImage.
  3. Downloads the Cursor app icon if it doesn't already exist.
  4. Conditionally creates or updates a .desktop file for the Cursor app.
#!/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://www.cursor.so/brand/icon.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-Version=latest
Comment=Cursor is an AI-first coding environment.
MimeType=x-scheme-handler/cursor;
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

How to Use:

You can review the script here before executing it. To install and run the script in one command, execute the following:

curl -sSL "https://gist.githubusercontent.com/arpagon/7cb8ff6361380725c893f5535fbbb58d/raw/b9e532bc1db5912d32693337694d941fa0ff60f7/CursorDesktopIntegrator.sh" | bash

Additional context

This script aims to make the user experience more seamless by automating what is otherwise a repetitive manual task. It's particularly useful for users who frequently update their Cursor .AppImage.

arpagon avatar Aug 31 '23 22:08 arpagon

Thanks

eric-naguras avatar Oct 13 '23 10:10 eric-naguras

Another version by @ChiTimesChi

https://gist.github.com/ChiTimesChi/5dd73abfb5677455705857b3c532c60c https://twitter.com/ChiTimesChi/status/1723682451283755284?t=ItCMQ0Z__ODRZMHpav0Vfg&s=19

arpagon avatar Nov 12 '23 17:11 arpagon

To work in Ubuntu 24.04

file: /etc/apparmor.d/cursor-appimage

# This profile allows everything and only exists to give the
# application a name instead of having the label "unconfined"

abi <abi/4.0>,
include <tunables/global>

profile cursor /home/{USER}/Applications/cursor*.AppImage flags=(unconfined) {
  userns,

  # Site-specific additions and overrides.  See local/README for details.
  include if exists <local/cursor>
}

run the parser

sudo apparmor_parser -r /etc/apparmor.d/cursor-appimage

This led me to the solution thanks @jrjohansen

https://github.com/laurent22/joplin/issues/10332#issuecomment-2065889431

arpagon avatar Apr 27 '24 01:04 arpagon

Great work! Would also shoutout AppImageLauncher, especially if you have multiple AppImages you want integrated

arimgibson avatar May 12 '24 14:05 arimgibson

Thankyou for solution!

kodai-bot avatar May 13 '24 01:05 kodai-bot

thanks a lot.

cogtoto avatar May 23 '24 19:05 cogtoto

thanks a lot!

Bhagvat080 avatar Jun 19 '24 04:06 Bhagvat080

how do you even install cursor on linux?

i have linux cloud VM which has no browser and want to install through CLI

from my local machine there is no linux download link on their website (it download mac version)

louis030195 avatar Aug 06 '24 08:08 louis030195

@louis030195 here's the link -- I'm on Linux, so it gives me the Linux download. Really unfortunate that they hide the other download options though. That's a huge usability error. You can spoof your user agent to fix but that's a pain.

https://downloader.cursor.sh/linux/appImage/x64

It's an AppImage: https://askubuntu.com/a/774520

arimgibson avatar Aug 06 '24 13:08 arimgibson

My own bash script https://gist.github.com/msanjeevkumar/edbfebbae976ab7b2cb2e4f22cb6b374

msanjeevkumar avatar Aug 15 '24 02:08 msanjeevkumar