[SOLVED] Need help with Linux .desktop launcher

Discuss problems related to FTL here. If you are having a problem or experiencing a bug PLEASE READ THE "MUST READ" POST.
Post Reply
psycoking
Posts: 2
Joined: Mon Sep 24, 2012 12:55 am

[SOLVED] Need help with Linux .desktop launcher

Post 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
Last edited by psycoking on Mon Sep 24, 2012 10:14 am, edited 1 time in total.
boa13
Posts: 808
Joined: Mon Sep 17, 2012 11:42 pm

Re: Need help with Linux .desktop launcher

Post 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
Forum janitor — If you spot spam, PM me the URL and/or the username of the spammer.
I have powers, moderator powers. I am not keen on using them, but will do so if needed.
psycoking
Posts: 2
Joined: Mon Sep 24, 2012 12:55 am

Re: Need help with Linux .desktop launcher

Post by psycoking »

Setting the path did the trick. Thanks for the help.
boa13
Posts: 808
Joined: Mon Sep 17, 2012 11:42 pm

Re: Need help with Linux .desktop launcher

Post by boa13 »

Good to hear. :)

Can you add [SOLVED] to the thread title?
Forum janitor — If you spot spam, PM me the URL and/or the username of the spammer.
I have powers, moderator powers. I am not keen on using them, but will do so if needed.
Currahee
Posts: 1
Joined: Mon Sep 24, 2012 10:15 pm

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

Post 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. :?:
DrNoid
Posts: 10
Joined: Sun Sep 16, 2012 9:40 am

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

Post 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
Icehawk78
Posts: 230
Joined: Tue Sep 18, 2012 4:55 pm

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

Post 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 "$@"
Creak
Posts: 1
Joined: Mon Dec 10, 2012 6:20 pm

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

Post 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 "$@"
Oskuro
Posts: 1
Joined: Sat Dec 22, 2012 12:51 pm

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

Post 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!
UltraMantis
Posts: 2125
Joined: Thu Sep 20, 2012 3:17 pm

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

Post 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-)
Report spam using the handy Report Button Mod.
Post Reply