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

Reboot and using wrong monitor #16

Closed
jriker1 opened this issue Oct 26, 2023 · 6 comments
Closed

Reboot and using wrong monitor #16

jriker1 opened this issue Oct 26, 2023 · 6 comments

Comments

@jriker1
Copy link

jriker1 commented Oct 26, 2023

Latest nightly of both Sunshine and MonitorSwap. Been working fine but recently remotely rebooted. Since I couldn't get in with Moonlight until I logged in once, I RDP into the Windows 11 computer and then used my batch file to disconnect:

@echo off 
ECHO You now have 30 seconds to start your project in Confire Player.
ECHO.
ECHO Your Remote Desktop session will then be disconnected from this computer.
TIMEOUT 5 /NOBREAK
for /f "usebackq skip=1 tokens=3" %%i in (`query user %USERNAME%`) do %windir%\System32\tscon.exe %%i /dest:console
exit 

I was then able to connect with Moonlight but was on Display 1 which is the one my monitor is connected to. How do I get it to use Display 2 which is the HDMI dongle after a reboot?

dummy.cfg.txt
primary.cfg.txt

At this point also if I go to the monitor attached it's blank so assuming when not connected thru Moonlight it's on thr 4k dongle and things are reversed.

@Nonary
Copy link
Owner

Nonary commented Nov 1, 2023

You don't have to use RDP to sign in anymore on the latest Sunshine version (0.21.0). You can simply just sign in using "Desktop", which will ignore the errors returned from prep commands if the user is not signed in. Once you have signed in using Moonlight, you end the stream and start it again.

As for making this work on reboots, it's a bit tricky to do that. Monitor swaps can only work after the user has signed in, and the display will not always be available when the user first signs in. I believe it would be possible but would require a lot of changes to the script and at best, it would only work after you've signed in, not at the logon screen.

@jriker1
Copy link
Author

jriker1 commented Nov 1, 2023

I went about some of this a different way but not helping overall. So I figured out without getting into Microsoft accounts how to auto login with my local/domain account in Windows 11. I then used the Multi Monitor app as a scheduled task on login to run the primary cfg. With this I end up with:

  1. I am able to connect pre 0.21.0 right after reboot without RDP or direct access to the desktop
  2. The monitor never comes up. I only see the monitor in the bios startup screens. When Windows kicks in the primary monitor goes blank and never comes back. Ever. Not sure if the primary is selected at anytime as it should be with my startup task running and how this module works but nothing shows.

@Nonary
Copy link
Owner

Nonary commented Nov 2, 2023

Well, if you're fine with automatic sign in, you can easily have it restore monitor by adding this to your startup commands (like task scheduler)

powershell.exe -executionpolicy bypass -windowstyle hidden -Command "& { . 'F:\sources\MonitorSwapAutomation\MonitorSwapper-Functions.ps1'; OnStreamEnd }"

Change the path to match your machine, what that does is essentially the same thing, it will poll until the monitor is restored, like when ending your stream.

@jriker1
Copy link
Author

jriker1 commented Nov 2, 2023

That though now to figure out why it doesn't work at all. So the below log (deleted a few pieces) when I'm disconnected seems to make you think it's successfully switched back to the monitor, but the screen is blank.


Windows PowerShell transcript start
Start time: 20231102145623
Configuration Name:
Machine: (Microsoft Windows NT 10.0.22621.0)
Host Application: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File C:\MonitorSwapper\MonitorSwapper.ps1 -async True
Process ID: 26452
PSVersion: 5.1.22621.2428
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.22621.2428
BuildVersion: 10.0.22621.2428
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1


Transcript started, output file is .\log.txt

Id Name PSJobTypeName State HasMoreData Location Command


1 MonitorSwapp... BackgroundJob Running True localhost ...
3 MonitorSwapp... BackgroundJob Running True localhost ...
Waiting for the next event to be called... (for starting/ending stream)
Processing event: Start
Dummy plug activated
Request to terminate has been processed, script will now revert monitor configuration.
Attempting to set primary screen, some displays may not activate until you return to the computer
Monitor(s) have been successfully restored.
Dummy Plug has been successfully deactivated!


Windows PowerShell transcript end
End time: 20231102145730


If it's helpful, I know the keyboard and mouse are working as I typed in ctrl-esc to pull up the search dialog and then typed in notepad. When I went thru Moonlight that notepad file was there. Monitor does show in device manager.

Also if this helps, believe before the latest Sunshine and Moonlight was working. Also based on the documentation I changed my config files for the monitor swap. Below is what they were before, and what they are now as far as how the monitor and dummy plug are listed:

The Dummy file used to list:
Dummy plug was [Monitor0] name \.\DISPLAY1
Monitor was [Monitor1] name \.\DISPLAY2

The Primary file used to list:
Monitor was [Monitor0] name \.\DISPLAY1
Dummy plug was [Monitor1] name \.\DISPLAY2

Now I have:

Dummy file:
Monitor is [Monitor0] name \.\DISPLAY1
Dummy plug is [Monitor1] name \.\DISPLAY2

Primary File:
Monitor is [Monitor0] name \.\DISPLAY1
Dummy plug is [Monitor1] name \.\DISPLAY2

So in the old one the displays would swap between Monitor0 and Monitor1 and also \.\DISPLAY1 and \.\DISPLAY2. Now they do not as the example I followed now doesn't do that. Not sure if that's relevant at all. Technically either way they list the correct monitor information to switch to.

@Nonary
Copy link
Owner

Nonary commented Nov 3, 2023

Might be a bug with multimonitor tool? Try the workaround #9

@jriker1
Copy link
Author

jriker1 commented Nov 3, 2023

I can give it a try but thinking I need to be on the primary monitor when doing this from what I'm reading. Of course can't get the primary monitor to show.

Do you think I need to disable MonitorSwap and ResolutionAutomation or maybe even Sunshine? If so can I do this without removing them? Maybe disabling the Sunshine service would kill everything and reboot?

@Nonary Nonary closed this as not planned Won't fix, can't repro, duplicate, stale Jan 27, 2024
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

2 participants