18 October 2011

Creating custom launchers for the Unity launcher in Ubuntu 11.10 (Minecraft Example)

After recently upgrading my Ubuntu from 11.04 to 11.10 I realised there was no simple way to add custom items to unity launcher. The Unity launcher only accepts .desktop files (see examples /usr/share/applications or desktop entry spec).

Below is an example of how to create a Minecraft custom Launcher, the assumption that you have already installed Java and have Minecraft downloaded and unpacked somewhere are made.
  • First we need to create a shell script file to launch the Minecraft launcher (I put mine in an apps directory within my home).
cd ~/
mkdir apps
gedit ~/apps/minecraft.sh
  • Paste the following content into gedit and save/close gedit 
#!/bin/bash
~/apps/java/bin/java -Xmx1024M -Xms1024M -jar ~/apps/minecraft/minecraft.jar net.minecraft.LauncherFrame
NOTE: The path to java (~/apps/java/bin/java) must match where ever you've installed java this can be found with the following command (to be run in a terminal):
which java
NOTE:  The path to minecraft.jar (~/apps/minecraft/minecraft.jar) must match the path to where ever you've unpacked the Minecraft download.
  • Next you will need to make the .sh file executable with the following command:
 chmod +x  ~/apps/minecraft.sh
  • Now we will create a new .desktop file (I put mine in a launchers directory within my home).
cd ~/
mkdir launchers
gedit ~/launchers/gnome-minecraft-panel.desktop
  • Paste the following content into gedit and save/close gedit
[Desktop Entry]
Name=Minecraft
Comment=Minecraft Launcher
Exec=~/apps/minecraft.sh
Icon=~/apps/minecraft/minecraft.png
Terminal=false
Type=Application
StartupNotify=true
Categories=GNOME;GTK;X-GNOME;
OnlyShowIn=GNOME;
# Translators: those are keywords for the date and time control-center panel
X-GNOME-Keywords=Minecraft;
X-GNOME-Keywords[en_GB]=Minecraft;
X-Ubuntu-Gettext-Domain=Minecraft Launcher
Name[en_GB]=gnome-minecraft-panel.desktop
NOTE: the paths to the (Exec & Icon) need to be to the .sh file and the Icon wish you want to use accordingly).
  • Open the file browser (Nautilus) and navigate to the lauchers directory within your home directory.
  • Drag the desktop into the Unity Launcher, done!

No comments:

Post a Comment