A way to run a program (here it is presented a bash script, but it can be adapted for any other program) that has a path relative to the .desktop file parent directory (tested on Gnome, KDE, Xfce, LXDE, LXQt, MATE, Cinnamon, Budgie desktop environments):
Gnome:
Exec=gnome-terminal -e "bash -c 'cd \"$(dirname "\"%k\"")\"; bash "./relative_file_path.sh" parameter1 parameterN'"
Gnome - newer:
Exec=gnome-terminal -- bash -c 'cd \"$(dirname "\"%k\"")\"; bash "./relative_file_path.sh" parameter1 parameterN'
KDE:
Exec=konsole -e "bash -c 'cd $(printf '"%s"' "$(dirname "%k")"); bash "./relative_file_path.sh" parameter1 parameterN'"
Xfce:
Exec=xfce4-terminal -e "bash -c 'cd \"$(dirname "\"%k\"")\"; bash "./relative_file_path.sh" parameter1 parameterN'"
LXDE:
Exec=bash -c 'cd "%k"&&bash "./relative_file_path.sh" parameter1 parameterN'
LXQt:
Exec=bash -c 'cd "%k"&&bash "./relative_file_path.sh" parameter1 parameterN'
MATE:
Exec=mate-terminal -e "bash -c 'cd \"$(dirname "\"%k\"")\"; bash "./relative_file_path.sh" parameter1 parameterN'"
Cinnamon:
Exec=gnome-terminal -e "bash -c 'cd \"$(dirname "\"%k\"")\"; bash "./relative_file_path.sh" parameter1 parameterN'"
Budgie:
Exec=tilix -e "bash -c 'cd \"$(dirname "\"%k\"")\"; bash "./relative_file_path.sh" parameter1 parameterN'"
An example of .desktop file for the Exec code shown above (except for LXDE and LXQt - for which replace Terminal=false with Terminal=true):
[Desktop Entry]
Version=1.0
Name=Name to display
Comment=A comment
Exec=...
Icon=utilities-terminal
Terminal=false //does not show the initial launcher app (terminal) window
Type=Application
Categories=Application;
For python3, replace bash "./relative_file_path.sh" parameter1 parameterN with python3 "./file_content_search.py" parameter1 parameterN, or - for other programs replace as needed