43

I want to create desktop entry for Inkscape AppImage. I'm having some issues because I don't have all MIME types or a clear idea about running that kind of app on desktop entry.

Does anyone know how I can achieve such a thing?

Flimm
  • 44,031
AtomX
  • 681
  • 1
  • 7
  • 15

6 Answers6

63

You can do it manually, or you can do it like it's described here: Registering an AppImage file as a desktop app in KDE.

Since you want to do it manually, you can do it like this.

  1. Download the official Inkscape AppImage.

  2. Make it executable, run: chmod +x inkscape.AppImage.

  3. Move it to an appropriate path, like ~/.local/bin.

  4. Extract the AppImage, run inkscape.AppImage --appimage-extract; a directory will be created called squashfs-root in the current working directory.

  5. Enter the directory squashfs-root and copy the desktop launcher org.inkscape.Inkscape.desktop to ~/.local/share/applications

  6. Edit the desktop launcher to point to the path of the AppImage followed by %F or %U or %u, i.e., Exec=/home/username/.local/bin/inkscape.AppImage %F

  7. Give the .desktop file executable permissions:

    chmod +x ~/.local/share/applications/org.inkscape.Inkscape.desktop
    
  8. Remove the directory squashfs-root.

Note: The AppImage file name doesn't have to have .AppImage; the system will know what it is. If the icon isn't displayed, the icon theme you're using is missing the file org.inkscape.Inkscape. You can also edit the desktop launcher to use whatever icon is provided by the icon theme.

Flimm
  • 44,031
Uri Herrera
  • 15,318
10

First, make sure it is executable: chmod u+x Inkscape.AppImage

Then, you would format your desktop file like this:

[Desktop Entry]
Name=InkScape
Exec=/path/to/appimage.AppImage
Icon=Inkscape
Type=Application
Categories=GTK;GNOME;Utility;
9

Using other answers I created a bash script that automatically extracts PNG icon from appimage and creates a .desktop file.

https://github.com/un1t/appimage-desktop-entry

Usage:

./appimage-desktop-entry.sh /path/to/Example.AppImage

Script:

#!/bin/bash
set -e
set -o pipefail

APPIMAGE_PATH=$1

if [ -z "$APPIMAGE_PATH" ]; then echo "Missing argument: appimage" exit 1 fi

if [ ! -f "$APPIMAGE_PATH" ]; then echo "File not found: $APPIMAGE_PATH" exit 1 fi

TEMP_SQUASHFS_PATH=$(mktemp -d) APPIMAGE_FULLPATH=$(readlink -e "$APPIMAGE_PATH") APPIMAGE_FILENAME=$(basename "$APPIMAGE_PATH") APP_NAME="${APPIMAGE_FILENAME%.*}" DESKTOP_ENTRY_PATH="${HOME}/.local/share/applications/$APP_NAME.desktop" ICON_FOLDER="${HOME}/.local/share/icons" mkdir -p "${ICON_FOLDER}"

if [ "$2" == "--remove" ]; then rm -f "$DESKTOP_ENTRY_PATH" find "${ICON_FOLDER}" -maxdepth 1 -type f -name "$APP_NAME.*" -delete echo "Removed" exit 0 fi

pushd $TEMP_SQUASHFS_PATH "$APPIMAGE_FULLPATH" --appimage-extract > /dev/null cd squashfs-root/

echo "Choose icon: " mapfile -t FILENAMES < <(find -L . -maxdepth 1 -type f ( -iname '.png' -o -iname '.svg' )) i=1 for filename in "${FILENAMES[@]}" do printf " %d) %s\n" "$i" "$filename" i=$((i + 1)) done

read -r SELECTED_INDEX

ICON_SRC=${FILENAMES[$((SELECTED_INDEX - 1))]} ICON_EXT="${ICON_SRC##*.}" ICON_DST="${ICON_FOLDER}/$APP_NAME.$ICON_EXT" cp "$ICON_SRC" "$ICON_DST"

cat <<EOT > "$DESKTOP_ENTRY_PATH" [Desktop Entry] Name=$APP_NAME StartupWMClass=$APP_NAME Exec="$APPIMAGE_FULLPATH" Icon=$ICON_DST Type=Application Terminal=false EOT

popd

rm -rf $TEMP_SQUASHFS_PATH

echo "Created"

Maarten
  • 234
un1t
  • 191
3

This is what worked for me.

  1. Download Inkscape-xxx.AppImage from inkscape.org.

  2. Copy it to /opt/inkscape/ folder and rename it to Inkscape.AppImage

  3. Make it executable chmod u+x Inkscape.AppImage

  4. Download inkscape-logo.svg file and copy it to /opt/inkscape/

  5. Create a a new file ~/.local/share/applications/inkscape.desktop

with the following entries.

[Desktop Entry]
Name=Inkscape
Exec=/opt/inkscape/Inkscape.AppImage %u
Icon=/opt/inkscape/inkscape-logo.svg
Comment=Draw Freely
Type=Application
Terminal=false
Encoding=UTF-8
Categories=Utility;
StartupNotify=true
StartupWMClass=org.inkscape.Inkscape

Edit: Run this command in terminal to show the app in applications list

update-desktop-database ~/.local/share/applications

Note: StartupWMClass=org.inkscape.Inkscape is very important to associate the running instance to the .desktop launcher. Also %u parameter at the end of Exec field is to list the application in the open with applications list.

To find the StartupWMClass entry of your application use

  1. for wayland use looking-glass
  2. for xorg run xprop | grep WM_CLASS in terminal and click on your application's window

Update: for Blender

  1. Download blender-x.x.x-linux-x64.tar.xz from blender.org.

  2. Extract it to directory /opt/blender/blender-x.x.x-linux-x64(or any other directory on your convenince)

  3. copy the file /opt/blender/blender-x.x.x-linux-x64/blender.desktop to

    ~/.local/share/applications/blender.desktop

  4. open the file ~/.local/share/applications/blender.desktop

find the following lines

Exec=blender %f
Icon=blender

and change to

Exec=/opt/blender/blender-x.x.x-linux-x64/blender %f
Icon=/opt/blender/blender-x.x.x-linux-x64/blender.svg
  1. Run this command in terminal

    update-desktop-database ~/.local/share/applications

resuser
  • 91
1

This is the answer that the AppImage documentation gives:

Integrating AppImages into the desktop

AppImages are standalone bundles, and do not need to be installed. However, some users may want their AppImages to be available like distribution provided applications. This primarily involves being able to launch desktop applications from their desktop environments’ launchers. This concept is called desktop integration.

appimaged

appimaged is a daemon that monitors the system and integrates AppImages. It monitors a predefined set of directories on the user’s system searching for AppImages, and integrates them into the system using libappimage.

See also: More information on appimaged can be found in appimaged.

AppImageLauncher

AppImageLauncher is a helper application for Linux distributions serving as a kind of “entry point” for running and integrating AppImages. It makes a user’s system AppImage-ready™.

AppImageLauncher must be installed into the system to be able to integrate into the system properly. It uses technologies that are independent from any desktop environment features, and therefore should be able to run on most distributions.

After install AppImageLauncher, you can simply double-click AppImages in file managers, browsers etc. You will be prompted whether to integrate the AppImage, or run it just once. When you choose to integrate your AppImage, the file will be moved into the directory ~/Applications. This helps reducing the mess of AppImages on your file system and prevents you from having to search for the actual AppImage file if you want to e.g., remove it.

To provide a complete solution for managing AppImages on the system, AppImageLauncher furthermore provides solutions for updating and removing AppImages from the system. These functions can be found in the context menus of the entries in the desktop’s launcher.

See also: More information about AppImageLauncher can be found in AppImageLauncher.

Flimm
  • 44,031
1

In addition to the previous amazing answers, I have found the following command useful to skip the extract and remove steps:

timeout 1 ./<whatever>.AppImage --appimage-mount \
   | xargs -I {} bash -c 'cp {}/*.desktop . -v'

which mounts the appimage (--appimage-mount) instead of extracting it; pipes the output of that command (the mount path) to xargs, invoking a new bash so we can use shell expansion after mounting; then within this new shell, copy over all desktop files to the current directory; finally closing the mount after 1 second

In a similar way, you can even automate the entire procedure (at your own risk :))

APPIMAGE=<whatever>.AppImage
chmod +x "$APPIMAGE"
timeout 1 ./"$APPIMAGE" --appimage-mount \
   | xargs -I {} find {} -name '*.desktop' \
   | head -n 1 \
   | xargs cat \
   | sed 's:^Exec=.*:Exec='"$(readlink -f "$APPIMAGE")"':' \
   > ~/.local/share/applications/"$APPIMAGE".desktop \
   && chmod +x ~/.local/share/applications/"$APPIMAGE".desktop

under the assumption that there is no : sign in the full appimage path

To fetch the icon as well, I use

APPIMAGE=<whatever>.AppImage
timeout 1 ./"$APPIMAGE" --appimage-mount \
   | xargs -I {} find {} -name '*.desktop' \
   | head -n 1 \
   | sed 's/\.desktop$/.png/' \
   | xargs -I {} cp {} ~/.local/share/icons -v

which assumes the desktop and icon file just have a different extension, which seemed to be the case for the few appimages I checked but I have no idea if it's part of the specification

Lennart
  • 111