General > On Topic

add menu item

<< < (2/3) > >>

Jerry:
Try this. In your home folder, make a new folder called mcserver, then inside that folder, make a file called mcexec, paste the following into it:


--- Code: ---#!/bin/bash
java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui
--- End code ---

Save it, right click on it, Make file executable. Make sure the server file minecraft_server.jar is in the same folder.

Open text editor and place the following in it:


--- Code: ---[Desktop Entry]
Name=Minecraft Server
Comment=Minecraft Server
Exec=x-terminal-emulator --geometry=95x25 -t "MC Server" -e "bash -c /home/user/mcserver/mcexec;bash"
Icon=/location/of/icon/file
Terminal=false
Type=Application
Categories=Game;
--- End code ---

Save the file as minecraftserver.desktop and place it in /home/user/.local/share/applications/

It should show up under Menu, Games.

davidwillis:
Thanks for the instructions.  Maybe I am not been clear on what I am trying to do.

Basically I can start a minecraft server my opening a terminal the cd ing to the correct directory, then run:
java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui

My kids use this to play minecraft together using our two computers at home.  However they never seem to be able to get it running when I am not home, so I would like to make a menu item that they could just click on to start the server.

I have been looking at making a file in /usr/share/applications (since the "Main menu" doesn't seem to have an option for the working directory).

I will keep looking and let you know if I get something that works.

Kirkx:
I can help you with getting the terminal window open. Then you will still need to figure out all the java staff.

1) Save the following test script as the file named "test" (no quote marks, no extension) here:


--- Code: ---/usr/scripts/
--- End code ---

http://i.imgur.com/ICr4XWj.png

Copy the contents of the file "test" from here:


--- Code: ---#!/bin/bash

bold=`tput bold`
normal=`tput sgr0`

echo "${bold}**********************"
echo "Test Script"
echo "**********************${normal}"
echo ""
echo ""
echo "Test script running ..."

echo ""
echo "Test script complete."
# sleep 5

--- End code ---

2) Hit Alt+F2 and run the following command:


--- Code: ---x-terminal-emulator --geometry=95x25 -t "My Custom Window Title" -e /usr/scripts/test
--- End code ---

To prevent the terminal window from auto-closing after executing the script change the command as follows:


--- Code: ---x-terminal-emulator --geometry=95x25 -t "My Custom Window Title" -e "bash -c /usr/scripts/test;bash"
--- End code ---

I have to admit that I'm not sure if that's the smartest, most correct method to keep the terminal open, so let's wait for others to confirm this.

By modifying the command shown above you can set the size of the terminal window (--geometery=WxH) or add the title (it's optional). Later, when you have all the parameters tweaked to your liking you can save the command permanently in Alacarte (Main Menu). DO NOT place the check mark next to "Launch in Terminal", just ignore that box.

davidwillis:
Thanks.   I have tried it with the full path as well, but it didn't make any difference.

paul59:

--- Quote from: davidwillis on August 11, 2014, 08:29:01 AM ---It works fine from command line (I do have to be in the correct folder when I run it though).

--- End quote ---

You could probably put the path to the .jar file like so rather than having to be in the same directory:


--- Code: ---java -Xmx1024M -Xms1024M -jar /path/to/archive/minecraft_server.jar nogui

--- End code ---

Paul

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version