0

I'm making some shortcuts to games I would normally run via terminal. For instance,

UT2004:

cd "$HOME/Unreal Tournament 2004/System/"  
./ut2004-bin-linux-amd64

My work so far:

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=true
Path=/home/nick/Unreal Tournament 2004/System/
Exec="/home/nick/Unreal Tournament 2004/System/ut2004-bin-linux-amd64"
Name=UT2004
Icon=/home/nick/Unreal Tournament 2004/Help/UT2004Logo.png

Unlike Unreal, EDuke32 actually runs, however I can tell it does so in $HOME, and starts littering it with log files. UT2004 doesn't start with the .desktop file at all. I figure, both of these problems could be solved if there was a way to specify the starting path for each application. Unfortunately, I cannot cd ... && ./... in the .desktop files.

How can I specify the "working directory" for each of these shortcuts?

1 Answer 1

0

The way I worked this out was to have a start-up script that changes to the correct directory and then starts the game. startup.sh :

#!/bin/bash
cd /path/to/game
game
cd "OLDPWD"

And then in the .desktop file use :

Exec=/bin/bash /path/to/startup.sh
3
  • that was going to be ny next guess, but wanted to avoid making extra scripts if .desktop has a built in feature. What's the "oldpwd" for, is it really necessary at the end of the script? May 26, 2020 at 16:45
  • It's only necessary if you continue the script after the game ends and need to be in the directory where you started.
    – bashBedlam
    May 26, 2020 at 18:32
  • I'll accept the answer as it is a valid solution, but still hoping to find one that doesnt require a tiny sh script in the middle. Might read the manual by freedesktop.org someday (i believe its them who made the standard) May 31, 2020 at 3:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .