Welcome, Guest. Please login or register.
November 09, 2024, 12:56:53 am

Pages: [1]
  Print  
Author Topic: Create a launcher on Linux  (Read 62693 times)
nicolas
Global Moderator
space invader
*****
Gender: Male
Posts: 107


pains-aux-raisins-based life-form.


WWW
« on: October 19, 2009, 11:36:59 pm »

Hi Grin
If you want to create a launcher for Machinarium on Linux, it's a bit more complicated than we can think first. It's quite easy anyway. Here the problem : according to how and from where the game is launched, Flash doesn't put the saved game to the same place, or doesn't see the data (all which are in these 00-11 folders). Roll Eyes

If you launch the game directly in double-clicking on the binary extracted from the tarball, it obviously work, and the saved game (if you have put the game in /opt/Machinarium/ for instance) is located here :
Code:
/home/-username-/.macromedia/Flash_Player/#SharedObjects/-strangething-/-localsomething-/opt/Machinarium/Machinarium/

If you make a launcher (in a menu, a panel, your desktop, whatever), the most simple command to put inside could have been (still with the game folder in /opt) :
Code:
/opt/Machinarium/Machinarium
But it doesn't work (black screen in the Flash player), for the simple reason that the game is not launched from its own folder, and doesn't see its data. Undecided

So, you have to do a very little script, that you can put inside a single command in your launcher. Tongue Something like :
Code:
bash -c "cd /opt/Machinarium/ && ./Machinarium"

In this way, it works, the game is launched, but it doesn't find your saved game from when you have launched it directly. Now, the saved game is located at :
Code:
/home/-username-/.macromedia/Flash_Player/#SharedObjects/-strangething-/-localsomething-/Machinarium/
So, if you want to use a launcher, more simple than an exploration through the folders each time you want to play, remember to move - with care - your saved game (Machinarium.sol) to its new location. Wink

« Last Edit: December 22, 2009, 10:08:46 am by Nicosmos » Logged
mikeypoo
little robot
*
Posts: 2


« Reply #1 on: May 19, 2010, 12:11:31 pm »

Hi Nicosmos, I tried to create your launcher in Ubuntu Karmic but had problems as it didn't actually active the program, but I suddenly remembered I often had to escape with slashes, so my new launcher is created this way and works fine:

sh -c "cd /home/$USER/machinarium/Machinarium\ Demo/ && ./Machinarium\ Demo"

Just thought it might help someone. I have noticed in fullscreen the mouse was somewhat erratic, but this might be able to be fixed easily, I have downloaded the demo and will experiment with it some more, great little game and clever graphics. About as quirky as Myst3
Logged
AlwaysLearning
little robot
*
Posts: 2


« Reply #2 on: December 21, 2010, 07:56:48 am »

Like a lot of users I have a fairly large screen running at 1920x1200, which means that even running Machinarium in its "100% mode" half of the screen is black.

I got around this issue my causing my App Launcher script to change resolution before starting Machinarium, ala:

Code:
#!/bin/sh
xrandr --size 1280x960
# A slight delay is recommended before starting Flash/Machinarium
sleep 2
cd /opt/Machinarium
./Machinarium
# Return to normal desktop resolution
xrandr --size 1920x1200

Naturally you should choose a resolution that suits your video card/screen combination (I have a 16:10 screen). According to the Machinarium FAQ the two screen modes are this size:
  • 100% mode: 1250x790px
  • 80% mode: 1000x632px
Logged
federer
little robot
*
Posts: 6


« Reply #3 on: May 07, 2011, 12:53:06 pm »

Hi Grin
If you want to create a launcher for Machinarium on Linux, it's a bit more complicated than we can think first. It's quite easy anyway. Here the problem : according to how and from where the game is launched, Flash doesn't put the saved game to the same place, or doesn't see the data (all which are in these 00-11 folders). Roll Eyes

If you launch the game directly in double-clicking on the binary extracted from the tarball, it obviously work, and the saved game (if you have put the game in /opt/Machinarium/ for instance) is located here :
Code:
/home/-username-/.macromedia/Flash_Player/#SharedObjects/-strangething-/-localsomething-/opt/Machinarium/Machinarium/

If you make a launcher (in a menu, a panel, your desktop, whatever), the most simple command to put inside could have been (still with the game folder in /opt) :
Code:
/opt/Machinarium/Machinarium
But it doesn't work (black screen in the Flash player), for the simple reason that the game is not launched from its own folder, and doesn't see its data. Undecided

So, you have to do a very little script, that you can put inside a single command in your launcher. Tongue Something like :
Code:
bash -c "cd /opt/Machinarium/ && ./Machinarium"

In this way, it works, the game is launched, but it doesn't find your saved game from when you have launched it directly. Now, the saved game is located at :
Code:
/home/-username-/.macromedia/Flash_Player/#SharedObjects/-strangething-/-localsomething-/Machinarium/
So, if you want to use a launcher, more simple than an exploration through the folders each time you want to play, remember to move - with care - your saved game (Machinarium.sol) to its new location. Wink



Its really a nice info which helps specially new users like me with the help of image is more usefull.
Logged

27. Love to spend time on forums.
Alex
Global Moderator
mayor robot
*****
Posts: 665



WWW
« Reply #4 on: December 03, 2011, 06:13:41 am »


Full disclosure: I know nothing about Linux.  But I found this thread about how to create a menu launcher for Machinarium in Ubuntu and thought it might help someone.

link: http://ubuntuforums.org/showthread.php?p=11506818

Logged
Nothor
little robot
*
Posts: 3


« Reply #5 on: January 04, 2014, 11:02:34 am »

To create a Launcher you can use the following script (copy-paste this code in a file located in the game folder). I use it for all the games I have, changing the names of the first 4 parameters.
For sure you need an icon (what you want) called Machinarium.png (look for it the internet) and place it in the game folder

IMPORTANT: I think there is ONLY 1 limitation, the game Path must to he WITHOUT "spaces".

Code:
#!/bin/bash

FILE="amanita-machinarium.desktop"
NAME="Machinarium"
EXEC="Machinarium"
ICON="Machinarium.png"

DIR="$( cd "$( dirname "$0" )" && pwd )"

if [ ! -e $DIR/$FILE ]; then

echo -e "[Desktop Entry]\nValue=1.0\nType=Application\nName=$NAME\nCategories=Game\nPath=\nExec=\nIcon=\nName[es]=$NAME" >> tmp; mv tmp $FILE

fi

sed "s;Path=.*;Path=$DIR;g" $FILE > tmp; mv tmp $FILE
sed "s;Exec=.*;Exec=$DIR/$EXEC;g" $FILE > tmp; mv tmp $FILE
sed "s;Icon=.*;Icon=$DIR/$ICON;g" $FILE > tmp; mv tmp $FILE

TARGET_DIR=$(xdg-user-dir DESKTOP)
if [ "$TARGET_DIR" == "" ]; then
TARGET_DIR=$HOME/Desktop
fi

cp $FILE $TARGET_DIR/$FILE
chmod +x $TARGET_DIR/$FILE
xdg-desktop-menu install $FILE

Then if you want to uninstall this launcher you can use this other script.

Code:
#!/bin/bash

FILE="amanita-machinarium.desktop"

xdg-desktop-menu uninstall $FILE

TARGET=$(xdg-user-dir DESKTOP)
if [ "$TARGET" == "" ]; then
TARGET=$HOME/Desktop
fi

if [ -e $TARGET/$FILE ]; then
rm $TARGET/$FILE
fi

I hope it will be useful.
« Last Edit: January 04, 2014, 11:05:19 am by Nothor » Logged
MestreLion
little robot
*
Posts: 3


« Reply #6 on: July 28, 2014, 10:34:28 am »

IMPORTANT: I think there is ONLY 1 limitation, the game Path must to he WITHOUT "spaces".

Get rid of this limitation by quoting your vars! Smiley

"$FILE"
"$TARGET"
etc...

Also, this ECHO -e is ugly, and there is no need to save as tmp, then rename to "$FILE", then replace values with sed. This could all be done in a single step. May I propose this?

Code:
cat > "$FILE" <<-EOF
[Desktop Entry]
Value=1.0
Type=Application
Name=$NAME
Categories=Game;
Path=$(printf '%q' "$DIR")
Exec=$(printf '%q' "$DIR/$EXEC")
Icon=$(printf '%q' "$DIR/$ICON")
EOF
Logged
MestreLion
little robot
*
Posts: 3


« Reply #7 on: July 28, 2014, 12:11:12 pm »


So, you have to do a very little script, that you can put inside a single command in your launcher. Tongue Something like :
Code:
bash -c "cd /opt/Machinarium/ && ./Machinarium"

In this way, it works, the game is launched, but it doesn't find your saved game from when you have launched it directly. Now, the saved game is located at :
Code:
/home/-username-/.macromedia/Flash_Player/#SharedObjects/-strangething-/-localsomething-/Machinarium/

The save game location only changed because you changed the way the executable is invoked, from absolute to relative. If you always use the absolute path, "/opt/machinarium/Machinarium", then saved games would be in the same place.

So the command should be:
Code:
bash -c "cd /opt/machinarium/ && /opt/machinarium/Machinarium"

I know an absolute path is redundant after the `cd`, but this way the save game location never changes.

Also, 2 remarks:

- Game should preferably be installed to `/opt/machinarium`, not `/opt/Machinarium`. Note the lowercase M. This is the standard location used .DEB install from Humble Bundle and Ubuntu Software Center.

- Why the "bash -c" single command thing? If this is a shell script, simply use "cd /opt/machinarium && /opt/machinarium/Machinarium". If this is a .desktop launcher, simply add a "Path=/opt/machinarium" line besides the "Exec=/opt/machinarium/Machinarium" line.
Logged
RobotJosef
space invader
*****
Gender: Male
Posts: 85

Eagerly awaiting Samorost 3


« Reply #8 on: July 28, 2014, 12:18:12 pm »

Aaahhh, I'm lost in the tidal wave of code!
Logged

FloexFan aka RobotJosef
Pages: [1]
  Print  
 
Jump to: