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

Adding a non-Steam game from a .desktop file ignores arguments in double quotes #8164

Closed
lat9nq opened this issue Oct 19, 2021 · 11 comments
Closed
Assignees
Labels
non-Steam application Shortcut added to Steam with the "Add a non-Steam Game..." option Steam client

Comments

@lat9nq
Copy link

lat9nq commented Oct 19, 2021

Your system information

  • Steam client version (build number or date): Oct 13 2021, at 19:47:24
  • Distribution (e.g. Ubuntu): Arch Linux
  • Opted into Steam client beta?: No
  • Have you checked for system updates?: Yes

Please describe your issue in as much detail as possible:

Adding a Non-Steam Game from a .desktop file ignores arguments in double quotes. The TARGET and START IN fields are populated seemingly properly. LAUNCH OPTIONS is blank.

Steps for reproducing this issue:

  1. Have a .desktop entry with the Exec line reading something like Exec=/path/to/program "/path/to/file"
  2. Add it as a Non-Steam Game
  3. Steam ignores the double-quoted argument. The LAUNCH OPTIONS field remains blank in Properties.
@smcv
Copy link
Contributor

smcv commented Oct 19, 2021

See also #5220, #4666, #3855, #711.

Since Steam already uses GLib, probably the easiest way to parse .desktop files correctly would be to parse Exec into a command and arguments with g_shell_parse_argv(), which is the same thing that's done to launch applications from the menus of GLib-based desktop environments like GNOME and XFCE.

@lat9nq
Copy link
Author

lat9nq commented Mar 12, 2022

If I try escaping characters in a file, i.e. Exec=/home/lat9nq/repos/yuzu/build/bin/./yuzu -g /home/lat9nq/ROMs/NX/Pok__mon\ Legends_\ Arceus\ v0\ \(01001F5010DFA000\).xci, Steam will reduce the arguments to -g /home/lat9nq/ROMs/NX/Pok__mon Legends_ Arceus v0 (01001F5010DFA000).xci which does not work (launching through Steam, the program receives the argument /home/lat9nq/ROMs/NX/Pok__mon).

If I add \" before and after the file name, it works in Steam (which reduces it to "/file/name" in LAUNCH OPTIONS) but is unusable on the host operating system (the application receives the string "/file/name").

Again like the original issue, simple double-quotes around the file name makes Steam ignore the arguments altogether.

The motivation behind this issue is yuzu-emu/yuzu/pull/6769

@smcv
Copy link
Contributor

smcv commented Mar 14, 2022

If I add \" before and after the file name, it works in Steam (which reduces it to "/file/name" in LAUNCH OPTIONS) but is unusable on the host operating system (the application receives the string "/file/name").

This suggests that Steam might be using the wrong syntax to parse the Exec line.

If/when someone with access to the proprietary parts of Steam looks into this, using GKeyFile followed by g_shell_parse_argv() would probably work better: that's how GLib-based desktop environments like GNOME and XFCE parse .desktop files, and Steam depends on GLib already, so it might as well use the same code.

@bertogg
Copy link

bertogg commented Aug 22, 2022

Looking at the related issues mentioned in the first comment, I'm not sure that they are all fixed as their status suggests. I'm testing this with the 15 Aug 2022 build of Steam.

Here's one simple .desktop file:

$ cat /tmp/FooBar.desktop 
[Desktop Entry]
Type=Application
Name=FooBar
Exec="/home/deck/Desktop/FooBar.sh"
$ touch /tmp/addnonsteamgamefile
$ xdg-open steam://addnonsteamgame/%2Ftmp%2FFooBar.desktop

This results in a new entry in the games library with

Target: ""/home/deck/Desktop/FooBar.sh""
Start in: ""/home/deck/Desktop"

(note the that there is four double quotes in the first case and three in the second one)

Now, if the shell script contains a space then we would have this the Exec line in FooBar.desktop:

Exec="/home/deck/Desktop/Foo Bar.sh"

This results in:

Target: ""/home/deck/Desktop/Foo"
Start in: ""/home/deck/Desktop"

(again, look at the number of double quotes).

The launch options are empty in both cases.

@kisak-valve kisak-valve added the non-Steam application Shortcut added to Steam with the "Add a non-Steam Game..." option label Jan 26, 2023
@smcv
Copy link
Contributor

smcv commented Feb 27, 2023

https://steamcommunity.com/groups/SteamClientBeta/announcements says the new Steam beta on 2023-02-22 had "Fixes for quotes surrounding shortcut exe and paths", which might help this?

@bertogg
Copy link

bertogg commented Feb 27, 2023

I just checked with the Feb 24 2023 build, and this is only partially solved.

Exec="/home/deck/Desktop/FooBar.sh"

This results in
Target: "/home/deck/Desktop/FooBar.sh"
Start in: "/home/deck/Desktop

This works, but note the missing double quote at the end (although it doesn't seem to have an effect in practice, i.e. the pwd of the actual process seems correct).


Exec="/home/deck/Desktop/Foo Bar.sh"

This results in
Target: "/home/deck/Desktop/Foo
Start in: "/home/deck/Desktop

This does not work.

@bertogg
Copy link

bertogg commented Feb 27, 2023

The Exec=/path/to/program "/path/to/file" case also doesn't work, the parameter is ignored if it comes with quotes.

@TTimo
Copy link
Collaborator

TTimo commented Feb 27, 2023

See #9237

@TTimo
Copy link
Collaborator

TTimo commented Feb 27, 2023

We have a few more things to check and fix.

@TTimo TTimo self-assigned this Mar 1, 2023
@TTimo
Copy link
Collaborator

TTimo commented Mar 2, 2023

fixed in next beta. we ran into a GIO bug (among other things): https://gitlab.gnome.org/GNOME/glib/-/issues/2930

@bertogg
Copy link

bertogg commented Mar 7, 2023

With the 2 Mar 2023 build:

[Desktop Entry]
Type=Application
Name=Foo Bar
Exec="/home/deck/Desktop/Foo Bar.sh" "/tmp/СТИМ ДЕК"

The result is:

Target: "/home/deck/Desktop/Foo Bar.sh"
Start in: /home/deck/Desktop/
Launch options: "/tmp/СТИМ ДЕК"

It seems to work perfectly fine now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
non-Steam application Shortcut added to Steam with the "Add a non-Steam Game..." option Steam client
Projects
None yet
Development

No branches or pull requests

5 participants