FrogTheFrog / moondeck-buddy

A server-side part of the MoonDeck plugin for the SteamDeck.
GNU Lesser General Public License v3.0
153 stars 9 forks source link

Linux version for support with Sunshine server? #4

Closed joeknock90 closed 1 year ago

joeknock90 commented 1 year ago

I love this idea as an alternative to steam remote play, which as of now is riddled with issues while using a Linux host.

Sunshine works extremely well for my usecase as an alternative. This project for a Linux host would solve all basically all of it's shortcomings for my use case.

I am not a developer or programmer, but if you think it's possible I'd be happy to provide any help I can.

Either way, thanks for your time!

FrogTheFrog commented 1 year ago

Heyo, I've already replied to this question more or less, so I will paste the quote:

Yes, on Linux the Sunshine is the equivalent for the official NVidia server. However, for me personally the experience was worse than remoteplay when I tried it so it went out of my sight immediately. However, buddy does not care whether it's a Sunshine or NVidia, but the linux specific API still needs to be implemented to detect if steam is running and what games are running at the moment. On Windows I've managed to find all the necessary info of it in the registry, on Linux... Who knows? I would welcome PR that implement this, but I don't plan any investigation soon.

In short, investigation needs to be done how and where Steam stores relevant info on Linux + API needs to be created to watch this info. A PR would be welcome :)

joeknock90 commented 1 year ago

Sorry, didn't see that anywhere!

Thanks for the breakdown! Wish I had more C++ experience. Hopefully someone smarter than me comes along.

Appreciate it!

sevansup commented 1 year ago

With Nvidia shutting down GameStream (announced this week), thereby breaking Moonlight--and also the new Steam Big Picture mode breaking other things, I wonder if ultimately Sunshine will be the way to go. It is sounding like it at the moment. Steam Link just isn't a good enough replacement yet sadly. https://nvidia.custhelp.com/app/answers/detail/a_id/5436

FrogTheFrog commented 1 year ago

With Nvidia shutting down GameStream (announced this week), thereby breaking Moonlight--and also the new Steam Big Picture mode breaking other things, I wonder if ultimately Sunshine will be the way to go. It is sounding like it at the moment. Steam Link just isn't a good enough replacement yet sadly. https://nvidia.custhelp.com/app/answers/detail/a_id/5436

I've already got the Sunshine working (for Windows only) and will be pushing the update soon'ish to the Testing store (maybe even before the new year). I will cancel NVidia faster, before it cancels me :D

FrogTheFrog commented 1 year ago

As of now the Buddy compiles on linux, but the proper implementation is still missing. There are 5 interfaces in https://github.com/FrogTheFrog/moondeck-buddy/tree/main/src/lib/os/linux that need to be implemented.

So if anyone else is reading this with a knack for linux and think they can help, please do :D

I myself will start working on SteamHandler interface. @joeknock90 don't expect anything soon as linux is still an unfamiliar ground for me, but at least the work has started...

joeknock90 commented 1 year ago

@FrogTheFrog

Nothing expected soon. My last 10 years of work have been bash and ansible as a sysadmin so I've basically forgotten everything else.

However, if there is assistance I can provide don't hesitate to reach out!

Thanks a bunch for putting some time into this!

XenHat commented 1 year ago

Consider me interested. I am taking a week off but when I am back, I'll be happy to help testing, at the very least. almost all my devices run Linux. I don't have much experience interfacing with Linux directly, but I have several years of bash, C# and C++ under my belt. If I can help in any way, I'd be happy to.

FrogTheFrog commented 1 year ago

Consider me interested. I am taking a week off but when I am back, I'll be happy to help testing, at the very least. almost all my devices run Linux. I don't have much experience interfacing with Linux directly, but I have several years of bash, C# and C++ under my belt. If I can help in any way, I'd be happy to.

Then we are on the same boat :D. As I mentioned before, I found where Steam stores info about currently running games just like on Windows, so I can at least start implementing SteamHandler interface.

As for the others interfaces, I have no clue what to do at the moment. It still in the investigation phase. For example, do I need to handle resolution change? Maybe the sunshine actually does it when grabbing the screen? If not, how the hell do you resize desktop on Wayland?

I will create an issue for each interface so feel free to post any findings/suggestions there.

joeknock90 commented 1 year ago

Sunshine can handle resolution changes with pre and post scripts on Linux. For instance I have 2 separate entries for when I have my deck docked and on the TV, and for when I'm just carrying it around that uses xrandr to change resolution. (Still using X11)

On wayland I believe wlr-randr exists for the same purpose as xrandr

I wonder if you would be able to take the current resolution reported by the Steam Deck with something like wlr-randr, detect if the host machine is running X11 or Wayland, then use the appropriate tool to change resolution at runtime.

Just some thoughts.

FrogTheFrog commented 1 year ago

Ty, that was some good info. As for steamdeck, I already grab its resolution and there's an option to also select a custom resolution from the list 😉

FrogTheFrog commented 1 year ago

I have implemented a partial linux support.

The only thing that's missing is 2 functions:

I have tested this on my crappy laptop with integrated intel GPU and these are some things I've noticed:

Until it is fully complete I will not provide builds. You can check the github workflows how to build it on linux.

I will now be taking a little break from further development as I'm feeling a little burnout and need to play some games :).

joeknock90 commented 1 year ago

I have implemented a partial linux support.

The only thing that's missing is 2 functions:

* to hide a cursor (don't know if that's even needed on linux)

* to change the resolution

I have tested this on my crappy laptop with integrated intel GPU and these are some things I've noticed:

* Steam's OLD big picture mode is crashing a lot for me when launching or closing games, or just at random (with or without stream)

* Steam's NEW big picture mode does not work for me at all so I can't test it

* Steam does not always detect that games have closed, so the Buddy does not detect it either (reproducible with https://store.steampowered.com/app/736260/Baba_Is_You/), however then the Steam Big Picture mode crashes after some time for whatever reason so it's a WIN WIN...

Until it is fully complete I will not provide builds. You can check the github workflows how to build it on linux.

I will now be taking a little break from further development as I'm feeling a little burnout and need to play some games :).

If you were physically close to me right now you'd have to fight my love off.

I'll build and test it out as well. Thank you for your hard work.

FrogTheFrog commented 1 year ago

I have implemented a partial linux support. The only thing that's missing is 2 functions:

* to hide a cursor (don't know if that's even needed on linux)

* to change the resolution

I have tested this on my crappy laptop with integrated intel GPU and these are some things I've noticed:

* Steam's OLD big picture mode is crashing a lot for me when launching or closing games, or just at random (with or without stream)

* Steam's NEW big picture mode does not work for me at all so I can't test it

* Steam does not always detect that games have closed, so the Buddy does not detect it either (reproducible with https://store.steampowered.com/app/736260/Baba_Is_You/), however then the Steam Big Picture mode crashes after some time for whatever reason so it's a WIN WIN...

Until it is fully complete I will not provide builds. You can check the github workflows how to build it on linux. I will now be taking a little break from further development as I'm feeling a little burnout and need to play some games :).

If you were physically close to me right now you'd have to fight my love off.

I'll build and test it out as well. Thank you for your hard work.

Heh 😁 Forgot to mention that I also had to fix a bug in Sunshine, so you must use the latest nightly (or compile it)

joeknock90 commented 1 year ago

NEAT

image

I was able to build it (in an ubuntu distrobox podman instance because I couldn't figure out dependencies on Arch. Oh well, what works works)

I had to restart my steam deck in order to get it to pair, and for some reason I also had to change the default port to something other than 59999. That's probably something I have configured somewhere though.

Still messing about with it. Couldn't get one thing to run but that's all I tried, so more to come.

Your speedy work is amazing. Thank you again for everything you've put into this. Enjoy some decompression time, I'm sure this wasn't easy.

Edit: Also yes I built and installed sunshine nightly.

FrogTheFrog commented 1 year ago

Be sure to enable debug logs 😉. I also semi hardcoded path to registry.vdf file, according to Valve that's ok. However if Steam is not detected that's where to look first. Maybe the path needs to change...

joeknock90 commented 1 year ago

Ooh Debug is helpful.

Yeah I'm almost 100% confident that the issue I'm having now purely sunshine and possibly mesa.

as far as I can tell, the buddy part is working great.

FrogTheFrog commented 1 year ago

Ooh Debug is helpful.

Yeah I'm almost 100% confident that the issue I'm having now purely sunshine and possibly mesa.

as far as I can tell, the buddy part is working great.

You can try to disable big picture mode, maybe it will help? Just comment out a few lines in Steam handler::launchSomething...

XenHat commented 1 year ago

Steam's NEW big picture mode does not work for me at all so I can't test it

I was able to get it working without hardware accelerated UI on my NVIDIA 3070 with the steam beta channel, if that's of any help.

I'll try compiling and testing the latest MoonDeckBuddy and Sunshine code later today!

EDIT: I'll have to wait for a Linux binary or more streamlined build steps because I can't get the repo to build. It wants a .pem key and that's my cue to give up. I'll check again in a week or so, enjoy your time off!

FrogTheFrog commented 1 year ago

Steam's NEW big picture mode does not work for me at all so I can't test it

I was able to get it working without hardware accelerated UI on my NVIDIA 3070 with the steam beta channel, if that's of any help.

I'll try compiling and testing the latest MoonDeckBuddy and Sunshine code later today!

EDIT: I'll have to wait for a Linux binary or more streamlined build steps because I can't get the repo to build. It wants a .pem key and that's my cue to give up. I'll check again in a week or so, enjoy your time off!

Make sure to fully checkout the submodules with git submodule update --init.

XenHat commented 1 year ago

Oh thank you so much! I always forget this part. 😓

XenHat commented 1 year ago

This works pretty well! https://youtu.be/XGE71bP8U9M

There's a minor glitch with an error page being overlaid transparently over the game when a notification pops up but at first blush this is good!

FrogTheFrog commented 1 year ago

There's a minor glitch with an error page being overlaid transparently over the game when a notification pops up but at first blush this is good!

I think you're talking about this: https://github.com/OMGDuke/protondb-decky/issues/46

FrogTheFrog commented 1 year ago

So I have finished porting what I could and here's a short summary:

All of this will apply as soon as #21 is closed.

joeknock90 commented 1 year ago

Ok, so just built and tested, and.... wow. Wow dude. I can't believe how fast you did that.

FrogTheFrog commented 1 year ago

Ok, so just built and tested, and.... wow. Wow dude. I can't believe how fast you did that.

I thought it was gonna be fun playing with Wayland, boy was I wrong. It's a dreaded callback hell in C++ with an awkward tree like structure with back references...

At that point I just wanted to get this done no matter the cost and forget about :D. Thanks to the HW acceleration tip from @XenHat , I at least managed to get Steam stable with the new beta update...

Enough ranting, I'm off to actually play games!

hjpaul7 commented 1 year ago

I feel like I'm really close..

Was able to build it, and I run MoonDeckStream from /build/src/stream and then MoonDeckBuddy from /build/src/buddy. Paired it with my deck, but when I launch a game from MoonDeckBuddy - it launches the game on my host PC but on the deck it says "Failed to find application MoonDeckStream".

Am I missing anything?

FrogTheFrog commented 1 year ago

I feel like I'm really close..

Was able to build it, and I run MoonDeckStream from /build/src/stream and then MoonDeckBuddy from /build/src/buddy. Paired it with my deck, but when I launch a game from MoonDeckBuddy - it launches the game on my host PC but on the deck it says "Failed to find application MoonDeckStream".

Am I missing anything?

You don't need to run MoonDeckStream, but add it to Sunshine like this: https://github.com/FrogTheFrog/moondeck-buddy/wiki/Sunshine-setup

hjpaul7 commented 1 year ago

I feel like I'm really close.. Was able to build it, and I run MoonDeckStream from /build/src/stream and then MoonDeckBuddy from /build/src/buddy. Paired it with my deck, but when I launch a game from MoonDeckBuddy - it launches the game on my host PC but on the deck it says "Failed to find application MoonDeckStream". Am I missing anything?

You don't need to run MoonDeckStream, but add it to Sunshine like this: https://github.com/FrogTheFrog/moondeck-buddy/wiki/Sunshine-setup

Worked! Thank you, so badass

FabianZettl commented 1 year ago

Hey guys, I want to get Moondeck running with my Nobara Desktop as a host. Any quick tutorial on how to build this? Never done it myself.

hjpaul7 commented 1 year ago

Hey guys, I want to get Moondeck running with my Nobara Desktop as a host. Any quick tutorial on how to build this? Never done it myself.

@FabianZettl there are the commands I ran to build it:

git submodule update --init
cmake -D CMAKE_C_COMPILER=/usr/bin/clang -D CMAKE_CXX_COMPILER=/usr/bin/clang++ -B build -G Ninja
cmake --build build
cmake install build
cd build
cd src/buddy
./MoonDeckBuddy

Edit: @FrogTheFrog since we have a Linux build now, could we include that in the release?

FrogTheFrog commented 1 year ago

Hey guys, I want to get Moondeck running with my Nobara Desktop as a host. Any quick tutorial on how to build this? Never done it myself.

@FabianZettl there are the commands I ran to build it:

git submodule update --init
cmake -D CMAKE_C_COMPILER=/usr/bin/clang -D CMAKE_CXX_COMPILER=/usr/bin/clang++ -B build -G Ninja
cmake --build build
cmake install build
cd build
cd src/buddy
./MoonDeckBuddy

Edit: @FrogTheFrog since we have a Linux build now, could we include that in the release?

A PR would be welcome for configuring this CMakeLists.txt file to package all the necessary binaries and whatnot, 'cause I have no experience with it yet on Linux :/. I'm just too lazy to spent hours playing around and hoping someone knowledgeable would come around :D

FabianZettl commented 1 year ago

Unfortunately I can't get it to work.. I just don't know enough about it. Hope that someone in the future can build an appimage or package for Moondeck on linux.

XenHat commented 1 year ago

Doesn't nobara use Wayland by default? Try Xorg.

XenHat commented 1 year ago

Hey guys, I want to get Moondeck running with my Nobara Desktop as a host. Any quick tutorial on how to build this? Never done it myself.

@FabianZettl there are the commands I ran to build it:

git submodule update --init
cmake -D CMAKE_C_COMPILER=/usr/bin/clang -D CMAKE_CXX_COMPILER=/usr/bin/clang++ -B build -G Ninja
cmake --build build
cmake install build
cd build
cd src/buddy
./MoonDeckBuddy

Edit: @FrogTheFrog since we have a Linux build now, could we include that in the release?

A PR would be welcome for configuring this CMakeLists.txt file to package all the necessary binaries and whatnot, 'cause I have no experience with it yet on Linux :/. I'm just too lazy to spent hours playing around and hoping someone knowledgeable would come around :D

This is what i've been using so far:

❯ cat build.sh
#!/bin/sh
sudo pacman -S --needed qt6-httpserver
cmake -DENABLE_CLANG_TIDY=False -DCMAKE_BUILD_TYPE:STRING=Release -B build -G Ninja
#sed -i 's/-mno-direct-extern-access//g' build/build.ninja
cmake --build build -j

I unfortunately have no experience dealing with CMake's native packaging utilities so I can't currently help there.

hjpaul7 commented 1 year ago

Hey guys, I want to get Moondeck running with my Nobara Desktop as a host. Any quick tutorial on how to build this? Never done it myself.

@FabianZettl there are the commands I ran to build it:

git submodule update --init
cmake -D CMAKE_C_COMPILER=/usr/bin/clang -D CMAKE_CXX_COMPILER=/usr/bin/clang++ -B build -G Ninja
cmake --build build
cmake install build
cd build
cd src/buddy
./MoonDeckBuddy

Edit: @FrogTheFrog since we have a Linux build now, could we include that in the release?

A PR would be welcome for configuring this CMakeLists.txt file to package all the necessary binaries and whatnot, 'cause I have no experience with it yet on Linux :/. I'm just too lazy to spent hours playing around and hoping someone knowledgeable would come around :D

Sorry I got busy and didn't see this 🙃

I can make a PR later today, should I attach a tar here as well with the binaries?

FrogTheFrog commented 1 year ago

Hey guys, I want to get Moondeck running with my Nobara Desktop as a host. Any quick tutorial on how to build this? Never done it myself.

@FabianZettl there are the commands I ran to build it:

git submodule update --init
cmake -D CMAKE_C_COMPILER=/usr/bin/clang -D CMAKE_CXX_COMPILER=/usr/bin/clang++ -B build -G Ninja
cmake --build build
cmake install build
cd build
cd src/buddy
./MoonDeckBuddy

Edit: @FrogTheFrog since we have a Linux build now, could we include that in the release?

A PR would be welcome for configuring this CMakeLists.txt file to package all the necessary binaries and whatnot, 'cause I have no experience with it yet on Linux :/. I'm just too lazy to spent hours playing around and hoping someone knowledgeable would come around :D

Sorry I got busy and didn't see this upside_down_face

I can make a PR later today, should I attach a tar here as well with the binaries?

Once you get CMake to package binaries correctly, please modify the github workflow a little, so that the binaries are uploaded like in Windows

XenHat commented 1 year ago

Once you get CMake to package binaries correctly, please modify the github workflow a little, so that the binaries are uploaded like in Windows

I tried doing this on my fork (because I wanted to turn off big picture, and build it using the provided workflow), and I ran into errors using the method Windows uses to generate the "installer", see https://github.com/XenHat/moondeck-buddy/blob/a4f263a1e3b8abbb5fe37c983813c87e4afeb131/CMakeLists.txt#L134

Hopefully this can be solved, as I failed to do so. Feel free to use anything in there.

FabianZettl commented 1 year ago

Any news here on a linux support for the buddy?

FrogTheFrog commented 1 year ago

Any news here on a linux support for the buddy?

It's supported, you just need to build it yourself for now. You can use GitHub workflow as an example

FrogTheFrog commented 1 year ago

It seems that new Steam update broke the legacy support and Valve no longer updates the registry.vdf file :/ Can anyone confirm that the Buddy has stopped working?

XenHat commented 1 year ago

i'm currently playing a game but I'll try in the next few days. poke me on discord if you need it done faster :)

On Sun, Jun 25, 2023, 10:04 Lukas Senionis @.***> wrote:

It seems that new Steam update broke the legacy support and Valve no longer updates the registry.vdf file :/ Can anyone confirm that the Buddy has stopped working?

— Reply to this email directly, view it on GitHub https://github.com/FrogTheFrog/moondeck-buddy/issues/4#issuecomment-1606105925, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHPLOHMAWXV7AKW63HQKYLXNBAPJANCNFSM6AAAAAASZKA3XQ . You are receiving this because you were mentioned.Message ID: @.***>

FrogTheFrog commented 1 year ago

@XenHat it seems to be related to this https://github.com/ValveSoftware/steam-for-linux/issues/9672.

Time for a workaround I guess...

FrogTheFrog commented 1 year ago

Github plz

XenHat commented 1 year ago

unfortunate.

On Sun, Jun 25, 2023, 15:43 Lukas Senionis @.***> wrote:

@XenHat https://github.com/XenHat it seems to be related to this ValveSoftware/steam-for-linux#9672 https://github.com/ValveSoftware/steam-for-linux/issues/9672.

Time for a workaround I guess...

— Reply to this email directly, view it on GitHub https://github.com/FrogTheFrog/moondeck-buddy/issues/4#issuecomment-1606233148, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHPLOGGTIIOVYSKIOSR2U3XNCIEHANCNFSM6AAAAAASZKA3XQ . You are receiving this because you were mentioned.Message ID: @.***>

hjpaul7 commented 1 year ago

You were able to workaround it?

FrogTheFrog commented 1 year ago

You were able to workaround it?

Yes. I'm watching child processes under Steam now. The relevant ones contain the AppId in the process' cmdline (linux only).

If that changes in the future, I have yet another possible workaround that should work on any OS, but is more complicated...

FrogTheFrog commented 1 year ago

@hustin-paul @XenHat and others, please test out this AppImage build if you have time: https://github.com/FrogTheFrog/moondeck-buddy/actions/runs/5380998997

I have updated the Wiki on how to use this.

If there are no issues or no one responds :D, I will merge the PR in a few days.

hjpaul7 commented 1 year ago

I'll test here in about an hour

Edit: Moonlight package broken in AUR, trying to fix

hjpaul7 commented 1 year ago

@FrogTheFrog

I'm not able to get it working properly. After running:

./MoonDeckBuddy --exec MoonDeckBuddy

and then adding same command but for MoonDeckStream in sunshine. Launch MoonDeckBuddy on steam deck -> PC resolution will change and Moonlight on deck returns "GeForce Experience returned error: Failed to start the specified application (Error 0)" and crashes.

Decided to test a bit and ran the command for MoonDeckStream outside of Sunshine:

./MoonDeckBuddy --exec MoonDeckStream

and launched from Deck, and it opened the game on the PC but then crashes on deck.

Edit: Launching straight from Moonlight on deck is working however.

Double Edit lol:

Looks like libprocps was needed. Installed that, checked out to your linux-deploy branch and built Buddy/Stream as before, and now it's working fine :)

FrogTheFrog commented 1 year ago

@hustin-paul Sorry, I don't get it. You said you build it yourself, what about the AppImage file? libprocps is included in there. Is it working or not?