Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with desktop file and xdg-open on Linux #24

Closed
JonnyHaystack opened this issue May 27, 2019 · 4 comments
Closed

Problems with desktop file and xdg-open on Linux #24

JonnyHaystack opened this issue May 27, 2019 · 4 comments
Labels
upstream-bug Something might be broken upstream (dependencies, tools, etc)

Comments

@JonnyHaystack
Copy link

JonnyHaystack commented May 27, 2019

The path to the AppImage file in the Exec field of the desktop file is wrapped in quotes, which causes errors such as the following when using xdg-open:
which: no Slippi-Launcher-1.4.4-x86_64.AppImage" in (./"/home/haystack/source)

This makes it so you cannot open .slp files from the Slippi site in your browser because the URL handling is done by xdg as well. Opening opening a .slp file from a file browser will also most likely be broken by this although it may depend on your file browser.

If I manually remove the quotes in the Exec field of the desktop file, then it works fine and the slippi:// URLs are handled properly and I can open the files directly with xdg-open as well.

The spec seems to imply that it should be fine to double quote the path, so I'm not entirely sure why it doesn't work. Could possibly be an upstream bug in xdg-utils.

Arguments may be quoted in whole. If an argument contains a reserved character the argument must be quoted. The rules for quoting of arguments is also applicable to the executable name or path of the executable program as provided.

For debugging purposes, here's the generated desktop file (~/.local/share/applications/appimagekit-slippi-desktop-app.desktop):

[Desktop Entry]
Name=Slippi Launcher
Comment=Slippi Desktop App for browsing and playing replays.
Exec=/home/haystack/source/Slippi-Launcher-1.4.4-x86_64.AppImage %U
Terminal=false
Type=Application
Icon=appimagekit-slippi-desktop-app
StartupWMClass=Slippi Launcher
X-AppImage-Version=1.4.4
MimeType=x-scheme-handler/slippi;
Categories=Development;
X-AppImage-BuildId=1K1bOeuJzPhoG9WcseHboZyGhZK
X-Desktop-File-Install-Version=0.24
X-AppImage-Comment=Generated by /tmp/.mount_SlippipSpjHL/AppRun
TryExec=/home/haystack/source/Slippi-Launcher-1.4.4-x86_64.AppImage
@eigenform
Copy link
Member

eigenform commented May 29, 2019

Weird - I get the same behavior. It turns out xdg-open is a shell script (didn't know that!) - maybe something it uses for parsing has changed in some way that breaks things like this. Gonna look into this.

edit: It looks like this is actually failure on part of xdg-mime? I'm on 1.13, see line 300-ish:

    command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | first_word`"
    command="`which "$command"`"
    ...

Seems like it wants to interpret those as literal quotes. Can't tell if it doesn't support quoting those fields, or if there's some weird issue.

edit again: Did some digging on this - perhaps it's electron-builder's fault?

electron-userland/electron-builder#2759

https://github.com/electron-userland/electron-builder/blob/62cb1ddd03853d8661cbcc322306056c56250e75/packages/app-builder-lib/src/targets/LinuxTargetHelper.ts#L68

@JonnyHaystack
Copy link
Author

JonnyHaystack commented May 29, 2019

Yes, looks like they went through the same thought process as me. The spec seems to indicate that it should be fine, but it isn't..

I did a quick experiment to see how spaces in file paths can be handled. Looks like if there's a space you just have to escape it with a backslash, which is the normal alternative to using quotes.

E.g. Exec=/home/haystack/source/Test\ Things/Slippi-Launcher-1.4.5-x86_64.AppImage %U

So does electron-builder not have the functionality to perform this escaping when creating desktop files? Admittedly xdg-utils' behaviour is clearly broken, but I'm surprised electron-builder uses quotes when it straight up doesn't even work with xdg-utils.

I think I'm gonna go open an issue upstream with xdg-utils and see how that goes. Seems like they track issues on their GitLab source mirror.

EDIT: Done, feel free to go give it a thumbs up 😉 https://gitlab.freedesktop.org/xdg/xdg-utils/issues/151

@eigenform
Copy link
Member

Yeah, I guess ideally xdg-mime respects the specification - unless there's some other technical reason why they wouldn't want to support escaping paths with quotes.

I'll leave this issue open until something happens somewhere upstream.

@eigenform eigenform added the upstream-bug Something might be broken upstream (dependencies, tools, etc) label May 29, 2019
@NikhilNarayana
Copy link
Member

electron-userland/electron-builder#2759 (comment)

This is fixed since we use 22.8.0+ now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream-bug Something might be broken upstream (dependencies, tools, etc)
Projects
None yet
Development

No branches or pull requests

3 participants