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

Add a priority list of displays, let me choose a display when I launch an application, or have the main monitor as a fallback in case the selected display isn't found #395

Open
UltraViolet24 opened this issue Jun 28, 2024 · 1 comment

Comments

@UltraViolet24
Copy link

Hi. Great program, been using it for a while. But an idea came to me yesterday and it's so annoyingly close to working, that I had to ask

I have a laptop that I sometimes use as a secondary display using spacedesk, and sometimes just stream my main monitor to it using Moonlight
This has worked fine, no issues. However I realized if I plugged in an extra cable from the gpu to my monitor, it would work essentially like a dummy plug, and I can now stream the second screen's contents to the laptop with all the goodies that come from sunshine

There is one thing stopping me from having this be really smooth, however. Because you can only set one display to be streamed:
image

If you try to launch it with the second screen "disabled", it won't work.
So because you need to have the "second monitor" active at all times in order to connect to it, if I wanted to go back to streaming my main monitor, I'd have to go into the web server and change the value there

My idea was the following
-Have a normal desktop app that I use to stream the main app normally
-Have a "second screen" app that would either boot with a selected display, or allow me to fire a prep-command (which would use something like MultiMonitorTool) to enable the second display, and then connect to it

I mean, there's also the idea of having the main monitor as a permanent fallback in case the monitor I chose isn't plugged in. That would still allow my laptop client to connect, choose an app, and have that app fire the prep command to enable monitor 2

Thank you for your time!

@UltraViolet24
Copy link
Author

Ok so I figured out how to do it in windows
I can now have one application that mirrors the main screen, and a second application that works as a second monitor.
It may not be the best approach but I got it to work and that's mostly what counts

My approach basically changes the primary display to a secondary video output, launches sunshine (which will target the secondary output), and then returns the primary display status to the main monitor

To make the "second monitor" application you need the following

Requirements:
multimonitortool
nircmd
A dummy display plug or just run 2 outputs to your monitor (I'm using displayport on my monitor, but at the same time there's an HDMI cable going from my GPU to my monitor, if it gets detected by windows, that's all that matters)

First of all make sure there's nothing on the Output Name that I mentioned in the post above, we need this to stream the primary display

Go into multimonitortool.exe and get the "Monitor ID" of both your main display and the secondary output. Throw that into notepad or somewhere and make sure to label which one is which. We'll use both.

Create an application in sunshine (I named mine "Second monitor" and set the following commands

Command Preparations
Do Command:
C:\Path\To\MultiMonitorTool\MultiMonitorTool.exe /SetPrimary "The secondary output's ID here"

Undo command
leave it blank

Do Command: (set here the resolution of the display you'll be using as the second monitor, for example this is for 1920x1200)
C:\Path\To\Nircmd\nircmd.exe setdisplay 1920 1200 32

Undo command: (optional) (sets it back to its native resolution)
C:\Path\To\Nircmd\nircmd.exe setdisplay 2560 1440 32

These commands will set the primary display to the secondary one (which would be the dummy plug or the second input in the monitor), and set the resolution of it to the device's resolution

Detached commands:
I set the path to a bat file I made that will handle resetting the primary display back to the initial one
C:\Path\To\Batch\secondScreenDetached.bat

The contents of the batch file are the following

@ECHO OFF
timeout 3 > nul
C:\Path\To\MultiMonitorTool\MultiMonitorTool.exe /SetPrimary "The primary monitor's ID here"

This batch file waits 3 seconds and then sets back the main monitor status to the primary display. 1 second doesn't work, 2 seconds maybe works? I haven't tested enough. 3 has been fine.

It should end up looking something like this
image

Save and apply. Now open the application from Moonlight. It should work.
If you see the primary display mirrored, just increase the timeout on the batch file. It may depend on the speed of your computer, I'm honestly not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant