getcursor / cursor

The AI Code Editor
https://cursor.com
25.17k stars 1.57k forks source link

Bash Script for Cursor App Desktop Integration on Linux Environments #844

Open arpagon opened 1 year ago

arpagon commented 1 year ago

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.

eric-naguras commented 1 year ago

Thanks

arpagon commented 1 year ago

Another version by @ChiTimesChi

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

arpagon commented 6 months ago

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

arimgibson commented 6 months ago

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

kodai-bot commented 6 months ago

Thankyou for solution!

cogtoto commented 5 months ago

thanks a lot.

Bhagvat080 commented 4 months ago

thanks a lot!

louis030195 commented 3 months ago

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)

arimgibson commented 3 months ago

@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

msanjeevkumar commented 3 months ago

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

jorcelinojunior commented 1 month ago

I've also developed a version that allows users to interactively select specific tasks to run, providing more control over the installation and update process. Here's my gist: cursor_appimage_manager.sh

Some screenshots:

Downloading the Latest Cursor App Version

Downloading the Latest Cursor App Version

Local Version Is Up-to-Date

Local Version Is Up-to-Date

Reinstalling or Updating to the Latest Downloaded Version

Reinstalling or Updating to the Latest Downloaded Version
pate0304 commented 2 weeks ago

@jorcelinojunior thanks for saving my time.

swpalmer-cl commented 1 week ago

@arpagon Doesn't work for me.

[2061376:1105/163821.307887:FATAL:setuid_sandbox_host.cc(158)] The SUID sandbox helper binary was found, but is not configured correctly. Rather than run without sandboxing I'm aborting now. You need to make sure that /tmp/.mount_cursoryBgkwK/chrome-sandbox is owned by root and has mode 4755.
0xRampey commented 2 days ago

Would also recommend this quick and easy graphical tool, Gear Lever to manage and add desktop entries for AppImages.