Like Us Like Us Facebook Subscribe Subscribe us YouTube Whatsapp Share us Whatsapp Query Send your queries

How to create a Linux application shortcut using Shell Script

How to create a Linux application shortcut using Shell Script

Do you want to create a Linux application shortcut using a shell script then this tutorial can help you. I have developed a custom electron based application called  “Automate Joy” and want to create a shell script that will create a application shortcut under development menu.

Screen shot creating Linux application shortcut using Shell Script

create Linux shortcut using shell script

First I have created a file called install.sh then opened a terminal to run command below to make it executable.

sudo chmod +x ./install.sh

Now inside install.sh written following code

#!/bin/bash
path=$(pwd)
appName="/automate-joy.desktop"
shortName="/usr/share/applications"
iconName="/img/icon.png"
dPath=$path$appName
iconPath=$path$iconName
shortPath=$shortName$appName

# echo $dPath
if [ -f "$shortPath" ]; then
echo "$shortPath already exists."
else

cat > $shortPath <<EOF
[Desktop Entry]
Encoding=UTF-8
Exec=npm start --prefix $path
Icon= $iconPath
Type=Application
Terminal=false
Comment=Automate Joy
Name=Automate Joy
GenericName=Automate Joy
StartupNotify=false
Categories=Development;IDE;TextEditor;
EOF

fi

After that I saved this file and opened a terminal and run below command to create software application icon in menu

sudo ./install.sh