LINUX LITE 7.2 FINAL RELEASED - SEE RELEASE ANNOUNCEMENTS SECTION FOR DETAILS


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
add menu item
#1
I am trying to add a menu item that will run a script from the terminal.  However after adding it, it does not open a terminal, and it does not run the script.

The menu item is simply to start a minecraft server.  It works fine running the command via command line, but I can't get the menu item to work.  Is there a way to set the directory path to run the script from (so it will find all the files it needs to run)?  And also why does it not open the terminal window, when I have that option checked (using main menu). 

Thanks
Reply
#2
Can you please show us your script (make sure it is executable) and the command you are running to start you server.
Reply
#3
Sure, this is what I run from command line to get the server up.

Quote:java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui

It works fine from command line (I do have to be in the correct folder when I run it though).

Reply
#4
...and the script?
Reply
#5
(08-11-2014, 12:29 PM)davidwillis link Wrote:It works fine from command line (I do have to be in the correct folder when I run it though).

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

Paul
Reply
#6
Thanks.  I have tried it with the full path as well, but it didn't make any difference.

Reply
#7
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/

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

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

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

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"

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.
LL 2.4, Xubuntu 14.04.2, Debian 8, Manjaro
Reply
#8
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.

Reply
#9
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

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;

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

It should show up under Menu, Games.
Reply
#10
I just solved this too Big Grin

Downloaded the server and put it in it's own directory. Edited eula.txt to signify agreement (won't run unless you've done this).

Created a launcher script in the server directory like so and made it executable:

Code:
#!/bin/sh
cd /home/paul/programs/minecraft-server/
java -Xmx1024M -Xms1024M -jar /home/paul/programs/minecraft-server/minecraft_server.1.7.10.jar

Modify the path to match your setup and add nogui to the end of the line beginning 'java....' if you don't need the god-mode Big Grin

Edited the main menu and added an item to the games category with launcher command like this:

Code:
/home/paul/programs/minecraft-server/launch-server.sh

Again modify path to suit.

Works fine, kids will be happy Big Grin

I've found the menu editor (alacarte or libremenu?) to be flakey - entries seem to disappear after editing sometimes.

Paul
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)