Page 1 of 1

[SOLVED] Need help with Linux .desktop launcher

Posted: Mon Sep 24, 2012 1:31 am
by psycoking
I'm fairly new to Linux and I need some help creating a shortcut for launching FTL from the app menu and desktop. I'm running Ubuntu 12.04 and have installed FTL to /opt/FTL. The game installed correctly and runs fine. I tried creating the following .desktop file, but clicking on it does nothing:

FTL.desktop:

[Desktop Entry]
Type=Application
Terminal=false
Exec=/opt/FTL/FTL
Name=FLT: Faster Than Light
Icon=/opt/FTL/data/exe_icon.bmp
Categories=Application;Game;

Not sure what I'm doing wrong, but if anyone could help me I would greatly appreciate it. :D

Re: Need help with Linux .desktop launcher

Posted: Mon Sep 24, 2012 7:07 am
by boa13
Unfortunately the game will only start if run from the /opt/FTL directory (the one where there is only the FTL script). I'm a bit fuzzy on the details, my Linux machine is turned off right now.

So, try adding this to your desktop file:

Code: Select all

Path=/opt/FTL

Re: Need help with Linux .desktop launcher

Posted: Mon Sep 24, 2012 7:24 am
by psycoking
Setting the path did the trick. Thanks for the help.

Re: Need help with Linux .desktop launcher

Posted: Mon Sep 24, 2012 8:39 am
by boa13
Good to hear. :)

Can you add [SOLVED] to the thread title?

Re: [SOLVED] Need help with Linux .desktop launcher

Posted: Tue Sep 25, 2012 1:28 am
by Currahee
I am not new to linux, yet I have a similar issue.

Code: Select all

[Desktop Entry]
Version=1.0
Type=Application
Name=FTL
Comment=Faster Than Light
Exec=/home/currahee/Games/FTL/FTL
Icon=/home/currahee/Games/FTL/data/exe_icon.bmp
Path=/home/currahee/Games/FTL
Terminal=false
StartupNotify=false
Does not run. I am running kubuntu 12.04 with xfce. Runs fine from a terminal, still does not work if changing 'Terminal=true' above.

What I ended up having to do was create a small script in my bin directory ~/bin/FTL:

Code: Select all

#!/bin/sh
cd ~/Games/FTL
./FTL
And point my launcher to that. Worked fine. :?:

Re: [SOLVED] Need help with Linux .desktop launcher

Posted: Tue Sep 25, 2012 7:34 am
by DrNoid
I think it's best if the FTL startup script is updated, so it first change to the directory the script resides in.
http://stackoverflow.com/questions/2425 ... le-resides

Just adding this should fix it:

Code: Select all

cd dirname $0

Re: [SOLVED] Need help with Linux .desktop launcher

Posted: Tue Sep 25, 2012 6:35 pm
by Icehawk78
DrNoid wrote:I think it's best if the FTL startup script is updated, so it first change to the directory the script resides in.
http://stackoverflow.com/questions/2425 ... le-resides

Just adding this should fix it:

Code: Select all

cd dirname $0
From your own link, I actually added this (since I have FTL symlinked in /usr/bin, yours didn't work):

Code: Select all

#!/bin/bash

# enter the game directory
SCRIPT=`readlink -f $0`
SCRIPTPATH=`dirname $SCRIPT`
cd $SCRIPTPATH/data

# run FTL
./FTL "$@"

Re: [SOLVED] Need help with Linux .desktop launcher

Posted: Mon Dec 10, 2012 6:27 pm
by Creak
I've got a whole working setup:

Here is my ftl.desktop:

Code: Select all

[Desktop Entry]
Encoding=UTF-8
Name=FTL: Faster Than Light
Exec=/home/creak/Games/FTL/FTL
Icon=/home/creak/Games/FTL/data/exe_icon.bmp
Terminal=false
Type=Application
MimeType=text/plain;
Categories=Game
And here is my FTL file (at the root of the game directory):

Code: Select all

#!/bin/bash

# enter the game directory
basedir="$(dirname $0)"
cd $basedir/data


# run FTL
./FTL "$@"

Re: [SOLVED] Need help with Linux .desktop launcher

Posted: Sat Dec 22, 2012 1:09 pm
by Oskuro
I know this has been solved, just wanted to contribute how I solved it:


Step 1: Extract the FTL folder to wherever you choose. I personally chose to install it into /opt/ as other games already installed there, my steps where:
a) Extract into /home/username/FTL
b) Open Terminal (CTRL+ALT+T)
c) sudo mv /home/username/FTL /opt/
Step 2: Create the Launcher Link. Create a new text file, and copy the following:

Code: Select all

[Desktop Entry]
Type=Application
Version=1.03.0
Name=FTL
Comment=Awesome Spacefaring Roguelike
Icon=/opt/FTL/data/exe_icon.bmp
Exec=/opt/FTL/FTL
Categories=Game;Simulation
Note that both the Icon and Execution paths should point to wherever you have extracted the FTL folder.

Save the text file as FTL.desktop

Step 3: Copy/Move the .desktop file to /usr/share/applications/
sudo cp FTL.desktop /usr/share/applications/FTL.desktop
This will make the link show up in the Ubuntu launcher, but it still won't work because of a little bothersome detail...

Step 4: Inside the FTL folder, there is a script also named FTL. Either edit it or make a copy (for safety I copied it into FTL.sh):
a) sudo cp /opt/FTL/FTL /opt/FTL/FTL.sh
b) sudo gedit /opt/FTL/FTL.sh
And change the following:
The problem is the line that reads:

# enter the game directory
cd ./data

As it is attempting to launch the app from the wrong path (relative path). Change it to this:

# enter the game directory
cd /opt/FTL/data

And it should work now.
Also, remember to update the .desktop file if you create a copy of the launcher script. In my case:
a) sudo gedit /usr/share/applications/FTL.desktop

Change:
Exec=/opt/FTL/FTL
Into:
Exec=/opt/FTL/FTL.sh
And that's it! Hope it works for you!

Re: [SOLVED] Need help with Linux .desktop launcher

Posted: Sat Dec 22, 2012 3:16 pm
by UltraMantis
Oskuro wrote:I know this has been solved, just wanted to contribute how I solved it...
Thanks for the detailed explanation, that's very cool of you. 8-)