Setting up a Minecraft launcher on Ubuntu 12.04, these steps worked for me, mostly pieced together from the various other tips.
In a terminal, first fetch a Minecraft image icon:
cd /usr/share/icons; sudo wget http://images.wikia.com/yogbox/images/d/dd/Minecraft_Block.svg
Then create a minecraft.desktop file (using the gedit text editor to keep it user-friendly; just enter the whole "gksudo ..." command at the command line):
gksudo gedit /usr/share/applications/minecraft.desktop
and paste in these contents, and then Save of course:
[Desktop Entry]
Name=Minecraft
Comment=
Exec=/opt/minecraft.sh
Icon=Minecraft_Block
Terminal=false
Type=Application
StartupNotify=true
(Note: you can also paste directly into the file by using
sudo sh -c 'xsel -ob > /usr/share/applications/minecraft.desktop'
if you have xsel
installed.)
Finally (almost), open up your file manager and go to /usr/share/applications - either click the Home Folder icon in your launcher and navigate, or here's the terminal quickie:
nautilus /usr/share/applications &
Locate your new Minecraft entry, and drag it over to your launcher bar.
At this point, you're practically done, except in this case I've created a little Minecraft starter script, saved in /opt/minecraft.sh, which assumes the minecraft.jar file is also saved in /opt. You can change all these "/opt" references to be wherever you've saved the original minecraft.jar file (be sure to change the Exec value in the minecraft.desktop file too).
The minecraft.sh file needs to contain just these three lines:
#!/bin/bash
cd $(dirname "$0")
java -Xmx1G -Xms512M -cp minecraft.jar net.minecraft.bootstrap.Bootstrap
(NOTE: for versions older than 1.6.1, you will need to use net.minecraft.LauncherFrame
instead of net.minecraft.bootstrap.Bootstrap
. The internal structure of the file and classes has changed as of 1.6.1.)
and of course that script needs to be executable, e.g. with the command
sudo chmod a+x /opt/minecraft.sh
If you have a system with more memory or notice poor performance when playing with higher render distances, you can increase the value of the -Xmx1G
flag as desired. This tells Java the maximum amount of memory it's allowed to use. -Xmx1G
means that it has a cap of 1 GB. -Xmx2G
would be 2 GB, -Xmx3G
would be 3 GB, and so on.
That's it! Using the starter script, and ensuring it cd's to the folder that contains the minecraft.jar file, seems to be a helpful step that other instructions overlooked.
Launcher icons are stored in /usr/share/applications
. Go to your terminal and type: sudo nautilus /usr/share/applications
, then right click the application you want, select Properties and click the icon on the properties window. Now you can set it to any icon you want.
*edits
*here is an example .desktop file.
[Desktop Entry]
Name=Give me a name!
Comment=Explain me here!
Icon=/home/t32/t32.png
Exec=/home/t32/bin/pc_linux/t32marm -c /home/t32/config_usb.t32
Terminal=false
Type=Application
Categories=This is important, select a category that is present
StartupNotify=true
*use one of the following as category: Accessibility, Customization, Education, Games,
Internet, Office, System, Accessories, Developer, Graphics, Media, Other
. Exec is the command to run, Icon is an absolute path to where the icon lives. Usually you wouldn't need to alter anything else. You may keep this as a scratch and reuse.
*copy this to a whatever-you-name.desktop
file, edit as needed and put the file in the /usr/share/applications
directory. If paths are true, it will pop up in the gnome menu. I don't know if lucid had Unity
or gnome3
, but if it has, when you search it by the name you gave it, it will be visible in the unity lens
, gnome activities
thing. If you have gnome2
, it would be grouped under the corresponding category in the applications menu.
*And this kind of launcher are so cute that they are valid in GNOME, KDE and (probably) all others.
Best Answer
There is no way to solve this in the general case. Whatever mechanism you come up with, I believe that it will always be possible to write a process that will elude you, unless you modify the way that processes are launched in the first place in order to track them that way.
Upstart has to deal with exactly the same problem to track if daemons are still running, and upstart job authors have to specify details (the number of forks) for upstart to track. Given that upstart cannot manage it without help, I don't think that you can, either. And upstart is even in control of the way that processes are launched, which I don't think you are here.
I think the best you can do is what you are doing already. Looking at
/proc/<pid>/stat
and/proc/<pid>/cmdline
is a reasonably general way, but still will not catch every case. Thepgrep
command wraps this. If you aren't already usingpgrep
, take a look at the pgrep manpage for options of things you can match against.Having said all that, I'm not convinced that you really need to do this in the first place. If you can't track the process, then I don't see how Unity could do this either. Wouldn't a better approach be to eliminate the application crashes in the first place? I would look into details of why your applications are crashing (surely that's a bug somewhere?), rather than trying to work around it as you have described. I wonder if this only affects Unity-aware applications which are calling back to Unity for extra functionality via DBus?