Wednesday, August 01, 2012

Gnome application launcher from command line

Here is a Plain Old Bash ( POB ) recipe that allows you to create a Desktop Gnome Application Launcher:
#!/bin/bash -e
# gnome-application-launcher.sh

USAGE="Usage: `basename $0` <name> <executablePath> <iconPath>"

if [ $# -ne "3" ] 
then
 echo $USAGE
  exit 1 
fi

name=$1
executablePath=$2
iconPath=$3

linuxUser=`logname`
launcherPath=$HOME/Desktop/$name.desktop

echo "[Desktop Entry]" > $launcherPath
echo "Version=1.0" >> $launcherPath
echo "Name=$name" >> $launcherPath
echo "Exec=$executablePath" >> $launcherPath
echo "Icon=$iconPath" >> $launcherPath
echo "Type=Application" >> $launcherPath
echo "Terminal=false" >> $launcherPath
chmod +x $launcherPath
chown $linuxUser:$linuxUser $launcherPath
Call it like this to create a Firefox launcher:
common/gnome-application-launcher.sh Firefox /usr/bin/firefox firefox-icon.png
Note we do not need to provide a full path for the Firefox application icon. You can also just say firefox.png as that one is included in /usr/share/pixmaps.

No comments:

Followers