Need some help creating a .desktop file for a shell script

You are likely correct, and thank you to everyone who’ve tried to help in this thread. Unfortunately my patience ran out at some point this afternoon and I simply reverted to using Lutris. Should I ever give it another attempt, I’ll update with a solution.

Celty, I registered here to help you. I’m not sure if you’re still in need for help, but for everyone seeing different behavior when executing bash shell scripts in console or through .desktop shortcut: I found the solution.
First of all, here’s a little script:

#!/bin/bash
echo $PATH
[[ $- == *i* ]] && echo ‘Interactive’ || echo ‘not-interactive’

What does it do? It shows you your PATH variable, and interactive your runtime or not. And if you will try to execute it you will have one set of paths and ‘interactive’ for console, while having other set of paths and ‘not-interactive’ for .desktop
For the same reason I had a problem activating conda environment through desktop shortcut. To launch your script through interactive runtime you will have to add just 2 symbols to your bash exec: "-i’. THAT’S IT!
For example, something like this .desktop file was working flawlessly to execute my script with my conda environment:

#!/bin/bash
[Desktop Entry]
Categories=Utility;Application;
Exec=bash -i ~/scripts/test.sh
GenericName[en_US]=Test
GenericName=Test
MimeType=
Name[en_US]=Test_nonG
Name=Test_nonG
Path=
StartupNotify=true
Terminal=true
TerminalOptions=\s--noclose
Type=Application
Version=1.0

while test.sh itself was about this:

#!/bin/bash -l
python --version
source activate py311
python --version
[[ $- == *i* ]] && echo ‘Interactive’ || echo ‘not-interactive’

Both of files were checked as “executable” and this is output I got:

Python 3.12.4
Python 3.11.11
‘Interactive’

while this was output without -i flag:

Python 3.10.12
/home/user/scripts/test.sh: line 3: activate: No such file or directory
Python 3.10.12
‘not-interactive’

I have been searching to resolve this issue for hours and the only thing better than the one answering it is being helpful to anybody. Cheers guys. Hope I helped to anybody here.

Three years later…

The user you want to help was last seen in 2023. Please make a new topic with a reference to this one. I’ll close here.

3 Likes