discord / discord-rpc

https://discordapp.com/developers
MIT License
1.06k stars 330 forks source link

Launching Steam games on Linux doesn't work (at least without a DE) #45

Open YaLTeR opened 6 years ago

YaLTeR commented 6 years ago

We register a desktop file containing xdg-open steam://rungameid/<number> %u, but it turns out that when we do xdg-open discord-<number>:// it actually runs xdg-open steam://rungameid/<number> discord-<number>:// (so it appends the original "url") and then complains about the second argument (since there's only supposed to be one argument to xdg-open).

Not sure how to handle this (is there a way to prevent that argument from getting appended?). Looking at the xdg-open source, for me (no DE, maybe that's the problem) the final line that executes the command is "$command_exec" "$@" where $command_exec turns out to be xdg-open steam://rungameid/<number> (from the .desktop file), and $@ is discord-<number>://.

crmarsh commented 6 years ago

Really the %u there is the problem, but when I tried excluding it nothing worked. Perhaps a bug in xdg-open? I guess a workaround would be to write out a shell file that ignores the parameter and just runs xdg-open steam://rungameid/<number>. 🤔

YaLTeR commented 6 years ago

In addition to that it doesn't seem to like the digits in the URL. There are two checks, one for file:// and another for URL which looks like echo "$1" | egrep -q '^[[:alpha:]+\.\-]+:', and this latter check suceeds for something:// if something contains digits. This results in xdg-open not even trying to open it as a URL for me.

YaLTeR commented 6 years ago

Although that doesn't really matter, since Discord itself doesn't use xdg-open to open the URL, does it?

crmarsh commented 6 years ago

Yeah, it does

YaLTeR commented 6 years ago

Perhaps there's a way to add something like discord://run/<id> similar to how Steam does it, and then it'll invoke the correct thing?

a-no-n commented 6 years ago

I got around this by adding ; \: to the end of the Exec line in the .desktop file. Until Discord_RegisterSteamGame is fixed you can at least register it manually with something like this:

const char* LAUNCH_CMD = "xdg-open steam://rungameid/<gameid> ; \\:";
Discord_Initialize(APPLICATION_ID, &handlers, 0, STEAM_APPID);
Discord_Register(APPLICATION_ID, LAUNCH_CMD);