@@ -273,12 +273,15 @@ if [[ "$SKIP_DESKTOP" == false ]]; then
273273 fi
274274
275275 # Copy icon to standard location
276- ICON_DIR=" /usr/share/icons/hicolor/512x512/apps/"
277276 if [[ " $USER_INSTALL " == true ]]; then
278- ICON_DIR=" $HOME /.local/share/icons/hicolor/512x512/apps/"
279- mkdir -p " $ICON_DIR "
277+ ICON_DIR=" $HOME /.local/share/icons/hicolor/512x512/apps"
278+ else
279+ ICON_DIR=" /usr/share/icons/hicolor/512x512/apps"
280280 fi
281281
282+ # Ensure the directory exists regardless of install type
283+ mkdir -p " $ICON_DIR "
284+
282285 # Create desktop file
283286 cat > " $DESKTOP_FILE " << DESKTOP_EOF
284287[Desktop Entry]
@@ -297,19 +300,20 @@ DESKTOP_EOF
297300 # Make desktop file executable
298301 chmod +x " $DESKTOP_FILE "
299302
300- if [[ -f " $INSTALL_DIR /resources/app.asar.unpacked/dist/icon.png" ]]; then
301-
303+ # 1. Find and copy the icon (try current paths first, then fallbacks)
304+ if [[ -f " $INSTALL_DIR /resources/app/icons/logseq.png" ]]; then
305+ cp " $INSTALL_DIR /resources/app/icons/logseq.png" " $ICON_DIR /logseq.png"
306+ elif [[ -f " $INSTALL_DIR /resources/app.asar.unpacked/dist/icon.png" ]]; then
302307 cp " $INSTALL_DIR /resources/app.asar.unpacked/dist/icon.png" " $ICON_DIR /logseq.png"
303-
304- # Update desktop file to use the copied icon
305- if [[ " $USER_INSTALL " == false ]]; then
306- sed -i ' s|Icon=$INSTALL_DIR/resources/app.asar.unpacked/dist/icon.png|Icon=logseq|' " $DESKTOP_FILE "
307- fi
308- fi
309- if [[ " $USER_INSTALL " == true && -f " $INSTALL_DIR /resources/app/icon.png" ]]; then
308+ elif [[ -f " $INSTALL_DIR /resources/app/icon.png" ]]; then
310309 cp " $INSTALL_DIR /resources/app/icon.png" " $ICON_DIR /logseq.png"
311310 fi
312311
312+ # 2. Update desktop file to use purely the icon name for system-wide installs
313+ if [[ " $USER_INSTALL " == false ]]; then
314+ sed -i " s|Icon=$ICON_DIR /logseq.png|Icon=logseq|" " $DESKTOP_FILE "
315+ fi
316+
313317 # Update desktop database
314318 if [[ " $USER_INSTALL " == false ]]; then
315319 update-desktop-database /usr/share/applications/ 2> /dev/null || true
@@ -323,7 +327,14 @@ rm -rf "$TEMP_DIR"
323327
324328# Verify installation
325329if command -v logseq > /dev/null 2>&1 ; then
326- INSTALLED_VERSION=$( logseq --version 2> /dev/null | head -1 || echo " unknown" )
330+ # Safely extract the version number from `package.json` as a priority, preventing the script from hanging during the launch of the Electron process.
331+ if [[ -f " $INSTALL_DIR /resources/app/package.json" ]]; then
332+ INSTALLED_VERSION=$( grep -m 1 ' "version"' " $INSTALL_DIR /resources/app/package.json" | cut -d' "' -f4 || echo " unknown" )
333+ else
334+ # Fallback Plan: Add a 2-second timeout to forcibly terminate the process, preventing the application from hanging.
335+ INSTALLED_VERSION=$( timeout 2 logseq --version 2> /dev/null | head -1 || echo " unknown" )
336+ fi
337+
327338 log_info " Logseq installed successfully!"
328339 log_info " Version: $INSTALLED_VERSION "
329340 log_info " Location: $INSTALL_DIR "
0 commit comments