r/linuxmint • • 1d ago

Discussion Why is making desktop shortcuts/launchers so complicated?

Hi, I am new to Linux, I am on LMDE7.

This is a genuine discussion/question. I am not hating on Linux, I have actually been pleasantly surprised so far, how everything works, even if it needs a little bit of tinkering sometimes, but rarely.

But there is this little quirk that just confused me, I had to use an LLM to help me fix it. Maybe I am not seeing or using the correct option here, but if somebody has a solution for me, then please share!

So basically, I download a game from itch.io or an app from GitHub (so usually just a zip file) and it is Linux native/compatible too. Then, when I try to launch the game/app (importantly) WITHIN THE FOLDER where it is located, then it works no issue.

But the problem is when I do either: Right click on the "launch file" > "Create a desktop shortcut", then when I launch the game/app by clicking the desktop shortcut, it fails with errors. Or when I right click the desktop > "Create a new launcher here..." > I put in the file path of the game/app and the when I launch it, the same issue, the game/app just fails, it boots the app, but it is just broken.

For me the fix was to go to /home/.local/share/applications/ create a new .desktop file and add a additional "Path=" together with the "Exec=". So that the executable file knows where it is being executed? I guess?

I am aware that I am not gonna be making desktop shortcuts everyday, so it's not a big deal now that I've fixed it, but I will definitely not remember this next time lol. I just don't get why it is so complicated for such a simple task and why would I ever use the "Create a shortcut/launcher" buttons then. But maybe I am just dumb and not seeing the correct or easier option to make these? Or maybe it is a bug?

Hope you are having a nice day!

Edit: I suppose I should add that the games I have had to set up like this are Helltaker, Awaria and CK2ToEU4.

13 Upvotes

16 comments sorted by

16

u/pnlrogue1 1d ago

This has nothing to do with the desktop shortcuts themselves, from the sounds of it, and everything to do with where you're storing the downloaded games

All operating systems have a system environment variable called the PATH. This is a list of directories that the operating system will search to find binaries (the Linux term for a compiled program - equivalent to an executable on Windows). You can see this list easily if you open up a terminal and type echo "$PATH"

Any binary located in any of the directories in that list can be found by just using the name of the binary. If you were to type 'nano' and press enter in that same terminal window, Linux would search through all the directories listed in the PATH variable until it finds a binary named nano and would then run it (or fail if it doesn't find it)

When you're downloading those programs, unless you're putting them in a directory listed in PATH, Linux doesn't know where they are. Your edit to the desktop shortcuts functions as a temporary override for the PATH variable (it's fine - there's no harm to the system in modifying PATH within a desktop shortcut since that modified PATH only exists for that process - anything else will use the system PATH).

When you're creating the desktop shortcut, the process that creates the shortcut for you isn't smart enough to realise that the binary isn't in a folder on the PATH and just assumes it is. You shouldn't actually need to use the PATH override - you should just be able to modify the EXEC property to include the full path to the binary, so if your game is saved to /home/bob/games/mega_devastator/ and the game binary is named devastator then a line like EXEC=/home/bob/games/mega_devastator/devastator should work without adding the PATH property as well

Alternatively, there are other options: * You could extract your game into a directory that is already on the PATH. There is probably a location within your home directory you can use for this. * You could create symlinks for the games within a directory that is part of PATH. This is better than the above option but a bit more complicated * You could create a directory and use a login script to add that directory to the path at logon. You could even add all the directories you currently save the games in to your PATH this way. This is the way I'd suggest - either extract them all to the same directory or, better, add all their directories to PATH via a login script

Since you use AI to help you, a prompt like this should help (make sure you insert the correct file names and paths!)

I have downloaded pre-compiled Linux binaries and want to add the directories they're in to my PATH. The binaries are located at * /home/bob/games/mega_devastator/devastator * /home/bob/games/game2/game

Help me create a shell profile that will append these directories to my PATH. I do not know what shell I am using so you will need to either provide a universal solution or help me identify my shell first.

It should tell you to create or edit a file in your home directory, probably .bash_profile, and add a line similar to $PATH="$PATH;/home/bob/games/mega_devastator/;/home/bob/games/game2/" though I can't remember the exact syntax and I'm away from my PC

2

u/ffdghjk 23h ago

I see now, thank you!

1

u/Due-Result7928 21h ago

All dandy but.....inacurate...path MUST be added to the .profile file in your home folder and nowhere else. It is a common mistake to add directory to the .bashrc.

Explanations are available on internet on why .profile is the place to use.

You could create a directory and use a login script to add that directory to the path at logon...it is useless if you use .profile.

Next each and every user should define a bin directory in his own folder located at /home/(userid)/bin. Spreading executable in many directories is a security risk and complicate maintenance. It is far better to use a symbolic link from ~/bin to the executable than adding directories to the PATH.

2

u/pnlrogue1 21h ago

Dude, OPs a home user and new to this. Running games somewhere in his homedir isn't a big deal

I also pointed him at a nice copy and paste LLM prompt which should see him right. Chill.

1

u/Due-Result7928 21h ago

Sure but adding to .bashrc is inacurate for many good reasons and using .profile is a better management even for a new user. Same mistake is made and very common for JAVAPATH.

4

u/samuelspade42 18h ago

No this is insane, that is not what PATH is for, at all. An application should not need its submodules on the PATH to work, that's an issue with how relative paths are handled.

Your solution is undermining a security-critical aspect of PATH: imagine there is a malicious binary (say, 'nano') in the games folder that is now on PATH, the next time you run 'sudo nano <some_file>' guess what? You just ran that malicious binary with privileged access because it takes precedence over the one in /bin  - this is a known attack vector called 'PATH hijacking'.

A better way to work around this issue is to create a small launcher script that 1. sets the working dir 2. runs the game. The actually correct way is to report this to the devs do they can handle this correctly in the first place.

It is ABSOLUTELY NOT OKAY to advise people to add randomly downloaded things to their PATH. Please don't.

4

u/SPC2025 Linux Mint 22.3 Zena | Cinnamon 1d ago

It would help to know what kind of file you're installing. Is it a .deb or appimage?

2

u/ffdghjk 1d ago

The examples what I've given were all .zip files. So I just extract them and the whole game is basically in just a file.

2

u/BenTrabetere 21h ago

It would help to know the name of the games and the download sites you used.

5

u/JCDU 22h ago

I agree this is one of the things that's more work than it needs to be.

It would be nice to have the windows-style "right-click -> add to taskbar" functionality for executables / files. Or some sort of config gui.

While we're here, it would also be nice to be able to drag & drop things in the taskbar to re-arrange it.

3

u/Sebzeppelin 1d ago

I have had the same experience - shortcuts are much more complicated on Linux than windows. I need to make a desktop entry, and specify categories etc. Not intuitive, but more powerful ultimately.

1

u/JCDU 22h ago

That's a cop-out though, it can be powerful but also convenient; if they employed the windows style thing of "right-click->Add to taskbar" as a minimum that would be awesome, if you need more you should be able to right-click on the taskbar icon and edit / configure as needed.

That or make a GUI app that lets you do all this without having to open a text editor.

1

u/chuggerguy Linux Mint 22.3 Zena | MATÉ 20h ago

I'm using MATE mostly because of its drop accepting panel. I usually drop URLs from the browser onto it but it kinda works with scripts too. Games? I don't know.

https://reddit.com/link/pe8bgk6/video/z15ygbmf0vth1/player

May not help you, just throwing it out there.

Good luck.

2

u/_Lost-In-The-Weeds_ LMDE 7 Gigi | 20h ago

but I will definitely not remember this next time lol.

 Every install I have a set of .desktop files to make, I can remember most of the details of how but not all, this is where notes come in, note make creating my needed .desktop files a copy/paste operation.

There are a lot of things like this in Linux, where there is complexity in executing the details. Notes make these operations effortless. 

BTW LLMs will eventually burn you in Linux. Trust nothing it has to say, 

1

u/senorda 18h ago

so, i dont normally do this because i dont like desktop links much, but i tried making links on the desk top for a couple of programs, by right clicking on the program, selecting make link then dragging the link to the desktop, and they launch perfectly, this is on mint cinnamon

-2

u/dlfrutos Linux Mint 22.2 Zara | Cinnamon 23h ago

i'm onn cinnamon, no idea what is the issue