Skip to content

Instantly share code, notes, and snippets.

@pnposch
Created January 17, 2026 13:35
Show Gist options
  • Select an option

  • Save pnposch/e9de659eb301c0ed84ff83eaa1927c01 to your computer and use it in GitHub Desktop.

Select an option

Save pnposch/e9de659eb301c0ed84ff83eaa1927c01 to your computer and use it in GitHub Desktop.

Revisions

  1. pnposch created this gist Jan 17, 2026.
    69 changes: 69 additions & 0 deletions add_to_gnome.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,69 @@
    #!/bin/bash

    # Define paths for Fedora 43 desktop and icon standards
    APPS_DIR="$HOME/.local/share/applications"
    ICON_DIR="$HOME/.local/share/icons/appimages"
    mkdir -p "$APPS_DIR" "$ICON_DIR"

    for app_file in *.AppImage *.appimage; do
    [ -e "$app_file" ] || continue
    chmod +x "$app_file"
    FULL_PATH=$(realpath "$app_file")
    APP_BASE=$(basename "$app_file" .AppImage)
    APP_BASE=$(basename "$APP_BASE" .appimage)
    FINAL_DESKTOP="$APPS_DIR/SCRIPT_${APP_BASE,,}.desktop"

    if [[ -f "$FINAL_DESKTOP" ]]; then
    echo "Skipping: '$APP_BASE' already integrated."
    continue
    fi

    echo "Processing $APP_BASE..."

    # 1. Extract internal metadata
    ./"$app_file" --appimage-extract > /dev/null 2>&1

    # 2. Extract and move the correct icon
    TARGET_ICON="$ICON_DIR/${APP_BASE,,}.png"
    if [ -L "squashfs-root/.DirIcon" ]; then
    # .DirIcon is a symlink, copy the actual file it points to
    cp -L "squashfs-root/.DirIcon" "$TARGET_ICON"
    elif [ -f "squashfs-root/.DirIcon" ]; then
    # .DirIcon is a regular file, move it
    mv "squashfs-root/.DirIcon" "$TARGET_ICON"
    fi

    # 3. Find and modify the internal desktop file
    INTERNAL_DESKTOP=$(find squashfs-root -name "*.desktop" | head -n 1)

    if [ -f "$INTERNAL_DESKTOP" ]; then
    # Copy the internal file but fix the Exec and Icon paths
    grep -vE "^(Exec|Icon|TryExec)=" "$INTERNAL_DESKTOP" > "$FINAL_DESKTOP"
    echo "Exec=$FULL_PATH" >> "$FINAL_DESKTOP"
    echo "Icon=$TARGET_ICON" >> "$FINAL_DESKTOP"
    echo "Comment=Integrated AppImage" >> "$FINAL_DESKTOP"

    # Ensure StartupWMClass exists; if not, use the internal Name
    if ! grep -q "StartupWMClass" "$FINAL_DESKTOP"; then
    WM_CLASS=$(grep "^Name=" "$FINAL_DESKTOP" | head -n 1 | cut -d'=' -f2)
    echo "StartupWMClass=$WM_CLASS" >> "$FINAL_DESKTOP"
    fi
    else
    # Fallback if no internal desktop file is found
    cat <<EOF > "$FINAL_DESKTOP"
    [Desktop Entry]
    Type=Application
    Name=$APP_BASE
    Exec=$FULL_PATH
    Icon=utilities-terminal
    StartupWMClass=$APP_BASE
    EOF
    fi

    # Cleanup
    rm -rf squashfs-root
    echo "Successfully integrated: $APP_BASE"
    done

    update-desktop-database "$APPS_DIR"