probonopd / linuxdeployqt

Makes Linux applications self-contained by copying in the libraries and plugins that the application uses, and optionally generates an AppImage. Can be used for Qt and other applications
Other
2.22k stars 414 forks source link

Desktop File: How to make Exec accept a file name with spaces? #503

Open ghost opened 3 years ago

ghost commented 3 years ago

Hi everyone!

It might be a dumb question, but I can't make linuxdeployqt accept a .desktop file where Exec holds a file name with spaces. I tried to escape spaces and single/double quote the whole name, but it doesn't seem to work. Does anyone know how to make it work? Could it be a bug? Cause it seems that Desktop Entry Specification supports spaces, although the language there is so unclear, so I might be wrong. I've found this SO thread and I see that it's a common problem.

probonopd commented 3 years ago

https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables states:

Quoting must be done by enclosing the argument between double quotes and escaping the double quote character, backtick character ("`"), dollar sign ("$") and backslash character ("\") by preceding it with an additional backslash character.

So if linuxdeployqt does not handle Exec="Some File" correctly then I'd consider it a bug. Do you have a minimal example?

ghost commented 3 years ago

So if linuxdeployqt does not handle Exec="Some File" correctly then I'd consider it a bug. Do you have a minimal example?

Thanks for the reply! I'll provide it ASAP.

ghost commented 3 years ago

Here, I've forked QtQuickApp, made CMake generate an executable with spaces, and changed Exec to Qt Quick App: https://github.com/GlebIgnatevEmlid/QtQuickApp.

Here's what I do:

git clone https://github.com/GlebIgnatevEmlid/QtQuickApp.git && cd QtQuickApp/
mkdir build && cd build
cmake -DQt5_DIR=~/Qt/5.15.2/gcc_64/lib/cmake/Qt5 -DCMAKE_INSTALL_PREFIX=build/AppDir -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --target install
wget https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage
chmod +x linuxdeployqt-continuous-x86_64.AppImage
./linuxdeployqt-continuous-x86_64.AppImage AppDir/share/applications/qtquickapp.desktop -qmake=$QMAKE -qmldir=../src -appimage

Which gives me the following result:

linuxdeployqt 7 (commit b469748), build 734 built on 2021-06-13 13:17:57 UTC
Desktop file as first argument: "AppDir/share/applications/qtquickapp.desktop"
desktopExecEntry: "Qt"
desktopIconEntry: "qtquickapp"
ERROR: Could not determine the path to the executable based on the desktop file
probonopd commented 3 years ago

Thank you very much @GlebIgnatevEmlid - marking this as a bug. PRs appreciated!