sonic2kk / steamtinkerlaunch

Linux wrapper tool for use with the Steam client for custom launch options and 3rd party programs
GNU General Public License v3.0
2.14k stars 72 forks source link

[Feature] Discord Rich Presence #511

Closed bayazidbh closed 2 years ago

bayazidbh commented 2 years ago

Hi, first, I want to thank you for the amazing tool. Recently I found this guide on how to get Discord Rich Presence working on Linux, however, the guide says that it has to be done manually per game. I simply think that steamtinkerlaunch would be the place that would make sense to automate its installation, as a global toggle of some sort.

I'm not sure if this is the right place to make this sort of request or even within the scope of stl, but I hope that it could be considered, thank you for your time.

frostworx commented 2 years ago

Hi, thanks for the feedback and the suggestion.

I barely use discord, but this looks easy to implement and also very useful for many people, so I'd consider an implementation.

I have some questions, though:

bayazidbh commented 2 years ago
  1. So far it seems to work but not always - I've tested it with two games so far.
    • With Shadowverse - a Unity game, it works fine - it says I'm playing that game.
    • With Sugar*Style, I noticed a few quirks. At the start it shows that I am playing 'proton', then sometimes it changes to me playing 'wine-preload' and other times it changes to 'Ethornell' which is the name of the game engine. It seems that it can hook to the wrong .exe, and even when it hooks to the right .exe it takes the game title from the window title so sometimes it might have the wrong title. Still, it does show that I am playing something.
  2. I am not entirely sure given that I'm not a programmer, so I don't know how to manually check the project's source code for potential issues. At the very least, it does not seem to cause any adverse issues.
  3. Same as above, but considering that projects such as rpcs3 and others implements their own discord rich presence, it should be an open API of sort so it should be legal.
  4. I don't mind making a draft for it, yes, but as a new user I'm not familiar enough with stl to post it myself.

Alternatively, I just did some more digging, and found this project: wine-discord-ipc-bridge. It seems to be more up to date, though it still seems to share the quirk of sometimes showing the wrong app name. The problem with this one is that the rpc-bridge seems to linger so even though I've closed the game, Steam still thinks the game is still running, requiring manual Stop command from Steam.

Overall, both project seems to work, but there are quirks that has to be accounted for. If this gets implemented, I'll make sure to make a note of it for the Wiki page.

frostworx commented 2 years ago

Thank you for elaborating. I didn't know that there is an open api, so I'd guess it is safe to use. General functionality, even if not for all games is fine. I just wanted to make sure that it is not outdated and therefore no longer working. Oh, thanks for linking to wine-discord-ipc-bridge. I think it would be better to use that instead of rpc-wine, because it is still actively developed. What do you think?

I'm confident that an automatic stop can be added to steamtinkerlaunch, so this likely won't be an issue.

Seems like everything is clarified and you're willing to contribute the wiki (it doesn't have to be big, just a basic description what it does and how to use/enable it in steamtinkerlaunch), so I'll accept the feature request. 👍

(likely won't happen too soon though)

bayazidbh commented 2 years ago

I think either one is fine, whichever works better for you. The wine-discord-ipc-bridge seems to account for Discord Flatpak (and planning for Discord Snap as well, from the look of it) as well, so I think that is the better option.

For the wiki, I'll prepare it once I could see how it's going to be implemented (I'd assume it's going to be a toggle in the per-game and global menu). Just give me a ping here or something. Thanks for the consideration!

frostworx commented 2 years ago

Just tested the commit from yesterday by installing discord via flatpak, setting this symlink ln -sf {app/com.discordapp.Discord,$XDG_RUNTIME_DIR}/discord-ipc-0 _(via)_

commenting in the line #USE_WDIB=1 # comment in for testing #511 and starting Grid: Combat Racing (listed as to be Rich Presence compatible here)

The wine-discord-ipc-bridge console opens and shows that it is connected, the game works as usual.

No idea where to go from here :) Would be nice, if you could test the current state as well @bayazidbh

frostworx commented 2 years ago

oh, sorry forgot to mention that the automatic download is not implemented yet as well. so for testing please download the latest winediscordipcbridge.exe from https://github.com/0e4ef622/wine-discord-ipc-bridge/releases and put it into the manually created directory /home/frostwork/.config/steamtinkerlaunch/downloads/wine-discord-ipc-bridge/ for testing.

frostworx commented 2 years ago

"complete" so far (see above commits). please test. _(USE_WDIB can be enabled in the per game settings)_

bayazidbh commented 2 years ago

I'm pretty new to github, do I just git clone master and then build to test?

I'll try to test it today or tomorrow, but it's been kinda a headache today because my govt decided to ban Steam.

frostworx commented 2 years ago

git clone https://github.com/frostworx/steamtinkerlaunch.git

and then a make install (as root) would install steamtinkerlaunch into the /usr prefix.

this should just work in the most cases, but it depends a bit on how you installed it previously (package management? - if you use arch for example there is also a steamtinkerlaunch-git package, which you could use - using the package management instead of a manual install is always, for every program the better and safer choice)

Oh my, sorry to hear that. I hope you find a stable workaround quickly... :(

bayazidbh commented 2 years ago

Oh my, sorry to hear that. I hope you find a stable workaround quickly... :(

The stable workaround is a VPN, which usually works, but Surfshark isn't exactly great or the most stable, and that applies double on Linux rn. But it's better than plain dnscrypt, which gets around the issue, but sometimes fails requiring manual retries (though unlike VPN, it is free with no risk). Sucks, but good enough is good. Hopefully it gets sorted out in the next few days.

Testing the WDIB on a freshly installed Manjaro with the steamtinkerlaunch-git AUR package and Discord Flatpak, the pipe-server did start:

image

But Discord didn't register any games. Tested with natively installed vanilla Discord, and the result is this:

image

sometimes it goes from pressure-vessel-wrap to the path to WIDB executable -- though I think that title part is editable but don't know how that would appear on others. But other times it goes from proton to the game properly:

image

and as can be seen by the history, it seems to register as a confirmed game as well. I don't know how to make it consistent, but it seems to work 50-80% of the time? So I guess we can just add that disclaimer in the wiki page and note that the user can at least edit the game name manually because at least a game IS detected by the Discord client.

That said, tested with both Discord Flatpak and Native, the game wouldn't run until I close the pipe-server terminal first. I don't know if that pipe-server terminal output affects anything, but it does work best when I close it as fast as I can.

I'm not sure how you'd go about the Discord Flatpak, which is supposed to work, both by your testing and upstream release. I tried it both before and after doing the symlink, but it didn't work? Is there a flatseal/flatpak overried I'm supposed to do on Discord Flatpak? I can confirm that the symlink doesn't affect Discord Native, though. Nor does betterdiscord seems to affect anything.

frostworx commented 2 years ago

this is weird. When testing with Grip: Compat Racing, the wine-discord-ipc-bridge console does not get stuck with "awaiting client connection" but actually does connect something. The game itself is properly executed together with wine-discord-ipc-bridge, so no need to close anything manually (it is started forked, so it should be non-blocking anyway - a log might help to analyse this(?)). Although the console says it is connected (it ouputs more than that btw, so it actually does something), discord doesn't list any registered games.

2022-07-31_09-37

No idea what else could be done, I don't use discord generally. I also don't use flatpak, so can't help here as well. Only set above symlink and started flatpak with flatpak run com.discordapp.Discord

bayazidbh commented 2 years ago

Alright, I tested it on my main gaming machine, a Garuda Linux (also Arch-based) older install on my PC. The behavior is almost the same -- works on normal Discord, doesn't work on Discord flatpak -- only the game managed to launch without requiring me to close the WIDB pipe terminal first.

I have stl set as a compatibility tools here, though, where on the Manjaro one I use it through the launch options. Also, maybe it's because I have Steam installed as a normal package? Maybe to use the Flatpak Discord Rich Presence I have to also run Flatpak Steam?

I'll just attach the logs that I got to not clutter the thread, but please tell me if there's something else you'd want to know or for me to try -- I'll try it as soon as I have some time.

453480_flatpak.log discord_flatpak.txt steam_flatpak.txt steamtinkerlaunch_flatpak-iscriptevaluator-453480.log steamtinkerlaunch_flatpak-launchSteamGame-STARTDEBUG.txt steamtinkerlaunch_flatpak.log flatseal_discord_flatpak_overrides.jpg 453480_native.log discord_native.log steam_native.log steamtinkerlaunch_native.log

frostworx commented 2 years ago

Thanks for testing. Can't find anything useful in the logs, though. It shouldn't matter if steamtinkerlaunch was started via launch option or compatibility tools - especially as the steam internal SLR functions seem to have changed again and therefore are probably not enabled either way.

I do not use Steam Flatpak here, so flatpak discord seems to work without Steam Flatpak (or is "Flatpak Discord Rich Presence" a different program/discord plugin which needs to be installed? I seriously do not know that stuff :))

I still wonder why you need to close the WIDB pipe terminal - it should start forked in the background and the game should start at the same time. your steamtinkerlaunch_flatpak.log is the log of steam starting "d3ddriverquery64.exe -d3d12" (it occasionally does that - for example when starting steam), so doesn't show anything related, and steamtinkerlaunch_native.log looks normal.

I'll try to test a bit more myself, but I do not really have a clue what it does or where it does it :D Chances are not bad, that I have a spare Grip: Combat Racing steam key left. So if you want to test with that (at least it seems to work looking at the console) just send me a PM on reddit or a mail (see first line in the Arch PKGBUILD)

frostworx commented 2 years ago

Just started Grip again with WIDB enabled, but this time using native discord instead of the flatpak. Same behavior, the WIDB console writes its stuff mentioned above, the game starts simultaneously. No idea what I can do or see now from discord side (registered games is full of multiple mostly older entries)

bayazidbh commented 2 years ago

Alright, it's weekend and I can do some testing. I'll try to test it on a clean Fedora and Ubuntu VM as well. Are there something in particular you want me check? Maybe some of the journalctl? I'll send you the Reddit PM now, though I did tested it with a few different games.

On my main Garuda (Arch-based) PC, using WIDB creates two issues for a while:

  1. Audio on other apps cannot play. I was watching the WAN Show on browser -- it loses the audio and I couldn't get it to play after pausing -- works fine as soon as I exited the game.
  2. When I exited the game, my second monitor becomes disconnected. I have to go to Display Settings and set it as enabled again.

I said for a while, because I disabled GameMode and FSR on the settings page, and now I can't reproduce it. The WIDB terminal output is still the same though, but overall it seems to work fine, now, barring Flatpak.

Could the WIDB taking the wrong sockets or too much sockets? One thing that's a commonality between my Garuda PC and Manjaro Laptop is that they're both KDE, and I think they both use pipewire, so maybe it's the way the session is set up between either Garuda, Manjaro, KDE, or WirePlumber. Here's my system details for the PC one, if that matters:

System Information

``` $ garuda-inxi System: Kernel: 5.18.15-265-tkg-pds arch: x86_64 bits: 64 compiler: gcc v: 12.1.0 parameters: intel_pstate=passive BOOT_IMAGE=/@/boot/vmlinuz-linux518-tkg-pds root=UUID=b17c3c0a-0fb4-4b17-95d5-5007eb71b44f rw rootflags=subvol=@ quiet splash rd.udev.log_priority=3 vt.global_cursor_default=0 loglevel=3 systemd.unified_cgroup_hierarchy=0 sysrq_always_enabled=1 amdgpu.runpm=0 radeon.dpm=0 amd_iommu=on iommu=pt mitigations=off Desktop: KDE Plasma v: 5.25.4 tk: Qt v: 5.15.5 info: latte-dock wm: kwin_x11 vt: 1 dm: SDDM Distro: Garuda Linux base: Arch Linux Machine: Type: Desktop Mobo: ASRock model: A320M-HDV R4.0 serial: UEFI: American Megatrends v: P2.30 date: 06/26/2019 CPU: Info: model: AMD Ryzen 5 3400G with Radeon Vega Graphics bits: 64 type: MT MCP arch: Zen/Zen+ note: check gen: 1 built: 2019 process: GF 12nm family: 0x17 (23) model-id: 0x18 (24) stepping: 1 microcode: 0x8108102 Topology: cpus: 1x cores: 4 tpc: 2 threads: 8 smt: enabled cache: L1: 384 KiB desc: d-4x32 KiB; i-4x64 KiB L2: 2 MiB desc: 4x512 KiB L3: 4 MiB desc: 1x4 MiB Speed (MHz): avg: 3594 high: 3937 min/max: N/A cores: 1: 3700 2: 3700 3: 2622 4: 3937 5: 3700 6: 3700 7: 3700 8: 3700 bogomips: 59205 Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm Vulnerabilities: Type: itlb_multihit status: Not affected Type: l1tf status: Not affected Type: mds status: Not affected Type: meltdown status: Not affected Type: mmio_stale_data status: Not affected Type: retbleed status: Vulnerable Type: spec_store_bypass status: Vulnerable Type: spectre_v1 status: Vulnerable: __user pointer sanitization and usercopy barriers only; no swapgs barriers Type: spectre_v2 status: Vulnerable, IBPB: disabled, STIBP: disabled Type: srbds status: Not affected Type: tsx_async_abort status: Not affected Graphics: Device-1: AMD Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] vendor: Tul / PowerColor driver: amdgpu v: kernel arch: GCN-4 code: Arctic Islands process: GF 14nm built: 2016-20 pcie: gen: 3 speed: 8 GT/s lanes: 8 link-max: lanes: 16 ports: active: DP-3,HDMI-A-1 empty: DP-1,DP-2,DVI-D-1 bus-ID: 01:00.0 chip-ID: 1002:67df class-ID: 0300 Display: x11 server: X.Org v: 21.1.4 with: Xwayland v: 22.1.3 compositor: kwin_x11 driver: X: loaded: amdgpu unloaded: modesetting alternate: fbdev,vesa gpu: amdgpu display-ID: :0 screens: 1 Screen-1: 0 s-res: 3286x1080 s-dpi: 96 s-size: 867x285mm (34.13x11.22") s-diag: 913mm (35.93") Monitor-1: DP-3 mapped: DisplayPort-2 pos: primary,left model: Toshiba TOSHIBA-TV serial: built: 2012 res: 1920x1080 hz: 60 dpi: 30 gamma: 1.2 size: 1600x900mm (62.99x35.43") diag: 1021mm (40.2") ratio: 16:9 modes: max: 1920x1080 min: 640x480 Monitor-2: HDMI-A-1 mapped: HDMI-A-0 pos: right model: Acer X163WL serial: built: 2011 res: 1366x768 hz: 60 dpi: 101 gamma: 1.2 size: 344x193mm (13.54x7.6") diag: 403mm (15.9") ratio: 16:9 modes: max: 1366x768 min: 720x400 OpenGL: renderer: AMD Radeon RX 570 Series (polaris10 LLVM 14.0.6 DRM 3.46 5.18.15-265-tkg-pds) v: 4.6 Mesa 22.1.4 direct render: Yes Audio: Device-1: AMD Family 17h/19h HD Audio vendor: ASRock driver: snd_hda_intel v: kernel bus-ID: 5-1:2 chip-ID: 301a:4602 pcie: class-ID: 0102 gen: 3 serial: speed: 8 GT/s lanes: 16 bus-ID: 07:00.6 chip-ID: 1022:15e3 class-ID: 0403 Device-2: Smartlink USB2.0 Device type: USB driver: hid-generic,snd-usb-audio,usbhid Sound Server-1: ALSA v: k5.18.15-265-tkg-pds running: yes Sound Server-2: PulseAudio v: 16.1 running: no Sound Server-3: PipeWire v: 0.3.56 running: yes Network: Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet vendor: ASRock driver: r8169 v: kernel pcie: gen: 1 speed: 2.5 GT/s lanes: 1 port: e000 bus-ID: 06:00.0 chip-ID: 10ec:8168 class-ID: 0200 IF: enp6s0 state: up speed: 100 Mbps duplex: full mac: IF-ID-1: docker0 state: down mac: IF-ID-2: tun0 state: unknown speed: 10 Mbps duplex: full mac: N/A IF-ID-3: virbr0 state: down mac: IF-ID-4: virbr1 state: down mac: IF-ID-5: vmnet1 state: unknown speed: N/A duplex: N/A mac: IF-ID-6: vmnet8 state: unknown speed: N/A duplex: N/A mac: Bluetooth: Device-1: Qualcomm Atheros type: USB driver: btusb v: 0.8 bus-ID: 1-9:4 chip-ID: 0cf3:e009 class-ID: e001 Report: hciconfig ID: hci0 rfk-id: 0 state: up address: bt-v: 2.1 lmp-v: 4.2 sub-v: 25a hci-v: 4.2 Info: acl-mtu: 1024:8 sco-mtu: 50:8 link-policy: rswitch hold sniff link-mode: peripheral accept service-classes: rendering, capturing, object transfer, audio, telephony Drives: Local Storage: total: 5.68 TiB used: 2.62 TiB (46.2%) SMART Message: Unable to run smartctl. Root privileges required. ID-1: /dev/sda maj-min: 8:0 vendor: Seagate model: ST1000VM002-1CT162 size: 931.51 GiB block-size: physical: 4096 B logical: 512 B speed: 6.0 Gb/s type: HDD rpm: 5900 serial: rev: SC23 scheme: GPT ID-2: /dev/sdb maj-min: 8:16 vendor: Western Digital model: WD40EZRX-00SPEB0 size: 3.64 TiB block-size: physical: 4096 B logical: 512 B speed: 6.0 Gb/s type: HDD rpm: 5400 serial: rev: 0A80 scheme: GPT ID-3: /dev/sdc maj-min: 8:32 vendor: Western Digital model: WDS240G2G0B-00EPW0 size: 223.58 GiB block-size: physical: 512 B logical: 512 B speed: 6.0 Gb/s type: SSD serial: rev: 0000 scheme: GPT ID-4: /dev/sdd maj-min: 8:48 type: USB vendor: Samsung model: ST1000LM024 HN-M101MBB size: 931.51 GiB block-size: physical: 512 B logical: 512 B type: HDD rpm: 5400 serial: scheme: GPT Partition: ID-1: / raw-size: 223.28 GiB size: 223.28 GiB (100.00%) used: 89.38 GiB (40.0%) fs: btrfs dev: /dev/sdc2 maj-min: 8:34 ID-2: /boot/efi raw-size: 300 MiB size: 299.4 MiB (99.80%) used: 576 KiB (0.2%) fs: vfat dev: /dev/sdc1 maj-min: 8:33 ID-3: /home raw-size: 223.28 GiB size: 223.28 GiB (100.00%) used: 89.38 GiB (40.0%) fs: btrfs dev: /dev/sdc2 maj-min: 8:34 ID-4: /var/log raw-size: 223.28 GiB size: 223.28 GiB (100.00%) used: 89.38 GiB (40.0%) fs: btrfs dev: /dev/sdc2 maj-min: 8:34 ID-5: /var/tmp raw-size: 223.28 GiB size: 223.28 GiB (100.00%) used: 89.38 GiB (40.0%) fs: btrfs dev: /dev/sdc2 maj-min: 8:34 Swap: Kernel: swappiness: 133 (default 60) cache-pressure: 50 (default 100) ID-1: swap-1 type: zram size: 31.27 GiB used: 0 KiB (0.0%) priority: 100 dev: /dev/zram0 Sensors: System Temperatures: cpu: 62.6 C mobo: N/A gpu: amdgpu temp: 66.0 C Fan Speeds (RPM): N/A gpu: amdgpu fan: 330 Info: Processes: 474 Uptime: 32m wakeups: 0 Memory: 31.27 GiB used: 14.96 GiB (47.8%) Init: systemd v: 251 default: graphical tool: systemctl Compilers: gcc: 12.1.1 clang: 14.0.6 Packages: 2463 apt: 0 pacman: 2412 lib: 559 flatpak: 51 Shell: Zsh v: 5.9 running-in: konsole inxi: 3.3.20 Garuda (2.6.5-1): System install date: 2022-02-27 Last full system update: 2022-08-06 ↻ Is partially upgraded: No Relevant software: NetworkManager Windows dual boot: Probably (Run as root to verify) Snapshots: Snapper Failed units: memavaild.service systemd-networkd-wait-online.service systemd-oomd.socket ```

I did caught a different issue, though, and that's if you have CheatEngine enabled, Discord says I'm playing Cheat Engine 7.2, most likely because it loads before the game's loaded.

At this point, maybe we should just put in the wiki, a note that WIDB is experimental and asking people to report their issues?

frostworx commented 2 years ago

Nah, there's nothing special to test, but I'd just like to see at least one game where the steamtinkerlaunch implementation is functional (so you can enable the option and get WDIB running automatically on game launch). so no testing WDIB on its own - sorry for the confusion.

As it seems to do what it is supposed to do (so far) using both discord native and discord flatpak here, I'd assume that your flatpak "problem" is not steamtinkerlaunch related. What do you think?

Thanks for the CheatEngine glitch. I'll see if this is fixable easily.

An experimental note in the wiki is a good idea, but I doubt that there can be done much from steamtinkerlaunch side, so I'd leave out the report issues part (else issues might be reported which should be reported on WIDB side).

bayazidbh commented 2 years ago

As it seems to do what it is supposed to do (so far) using both discord native and discord flatpak here, I'd assume that your flatpak "problem" is not steamtinkerlaunch related. What do you think?

Yeah, seems about right. I've tested with GRIP, and it does function correctly with GRIP. What the WDIB cannot do seems to be help with flatpak Discord if the game itself doesn't use \\.\pipe\discord-ipc-0.

I'll make sure to note the relevant caveats in the Wiki page. Will stl be able to download the WIDB automatically, or will that remain manual for now? On that note, is there a place to discuss things or asks questions that aren't on Github Issues?

frostworx commented 2 years ago

Yeah, until nothing dramatically changes on the WDIB project page, steamtinkerlaunch will always download the latest version automatically. I'd guess the WDIB project doesn't cover every possibility to be feature complete (or it is not even possible at all - no idea), so probably there is not much more which could be done from steamtinkerlaunch view.

Until they are steamtinkerlaunch related, you could always open a discussion on r/SteamTinkerLaunch I will spend far less time on steamtinkerlaunch in the near future, so I hope the community rises to help itself also over there.

bayazidbh commented 2 years ago

Alright, I've submitted the WDIB wiki page. Please check and tell me if there's any issues. If there's not, I'll add it to the wiki's index page tomorrow -- should be in the Tools section, right?

frostworx commented 2 years ago

Wow, great wiki! Thanks a lot for the contribution! 👍 Yeah, I guess Tools section is a good choice :)