@@ -14,6 +14,12 @@ DESKTOP_APP_NAME="Phoenix Code"
1414DESKTOP_ENTRY=" $DESKTOP_DIR /$DESKTOP_ENTRY_NAME "
1515SCRIPT_NAME=" phcode" # Name of the script to invoke the binary
1616BINARY_NAME=" phoenix-code"
17+ # STARTUP_WM_CLASS is set to the binary name and used as the application's class name in the desktop file.
18+ # This class name helps the desktop environment manage application windows. If native libraries are missing
19+ # and the application needs to be launched via a script instead of directly, this variable is updated
20+ # accordingly before the desktop file is created.
21+ STARTUP_WM_CLASS=$BINARY_NAME
22+
1723
1824declare -a MIME_TYPES=(
1925 " text/html"
@@ -384,19 +390,20 @@ create_launch_script_with_gtk() {
384390
385391 local binary_path=" $1 "
386392 local binary_name=" $BINARY_NAME "
387-
388- local realBin=" $binary_path /$binary_name .app "
393+ local original_bin= $binary_name .app
394+ local realBin=" $binary_path /$original_bin "
389395 mv " $binary_path /$binary_name " " $realBin "
390396 echo " Creating a launch script for Phoenix Code with GTK libraries..."
391397 cat > " $binary_path /$binary_name " << EOF
392398#!/bin/bash
393399SCRIPT_DIR=\$ (dirname "\$ (readlink -f "\$ 0")")
394400export LD_LIBRARY_PATH=\$ SCRIPT_DIR/gtk:\$ LD_LIBRARY_PATH
395- exec \$ SCRIPT_DIR/$binary_name .app "\$ @"
401+ exec \$ SCRIPT_DIR/$original_bin "\$ @"
396402EOF
397403 chmod +x " $binary_path /$binary_name "
398404
399405 echo -e " Launch script created at: $binary_path /$binary_name "
406+ STARTUP_WM_CLASS=$original_bin
400407}
401408
402409# Verify and Install Dependencies Function
@@ -557,7 +564,7 @@ Terminal=false
557564MimeType=$MIME_TYPES_STRING ;
558565Categories=Development;IDE;Utility;TextEditor;
559566StartupNotify=true
560- StartupWMClass=phoenix-code
567+ StartupWMClass=$STARTUP_WM_CLASS
561568EOF
562569 echo -e " ${YELLOW} Desktop entry created at: $DESKTOP_ENTRY ${RESET} "
563570 # Update the desktop database for GNOME, Unity, XFCE, etc.
0 commit comments