Last active
September 25, 2024 16:53
-
-
Save espeon/221454a358019d4422eca78ecff103d3 to your computer and use it in GitHub Desktop.
set and reverse monitor resolution, invoke via `powershell.exe -executionpolicy bypass -windowstyle hidden -file "C:\Your\ScriptHere.ps1"`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $content = Get-Content -Path "$env:APPDATA\sunshineres-resolution.txt"; | |
| $height = ($content | Select-String 'h:').ToString() -replace '\D+', ''; | |
| $width = ($content | Select-String 'w:').ToString() -replace '\D+', ''; | |
| $fps = ($content | Select-String 'f:').ToString() -replace '\D+', ''; | |
| # for debug | |
| echo "qres /x:$width /y:$height /r:$fps" | Out-File -FilePath "$env:APPDATA\sunshineres-latest-rev-dbg.txt"; | |
| qres /x:$width /y:$height /r:$fps |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $resolution = (Get-WmiObject -Class Win32_VideoController).VideoModeDescription; | |
| $height = ($resolution -split ' x ')[2]; | |
| $width = ($resolution -split ' x ')[1]; | |
| $qresRaw = qres /S | |
| $fps = ($qresRaw | Select-String -Pattern "\d+ Hz").Matches.Value.Replace(" Hz", "") | |
| $sunh = $Env:SUNSHINE_CLIENT_HEIGHT | |
| $sunw = $Env:SUNSHINE_CLIENT_WIDTH | |
| $sunfps = $Env:SUNSHINE_CLIENT_FPS | |
| # NOT for debug - file used by revmonres.ps1 to reset resolution after client disconnect | |
| $output = "h: $height`nw: $width`nf: $fps`nsunshine_spec_dbg: $sunw x $sunh - $sunfps fps"; | |
| $output | Out-File -FilePath "$env:APPDATA\sunshineres-resolution.txt"; | |
| echo "qres /x:$Env:SUNSHINE_CLIENT_WIDTH /y:$Env:SUNSHINE_CLIENT_HEIGHT /r:$Env:SUNSHINE_CLIENT_FPS" | Out-File -FilePath "$env:APPDATA\sunshineres-latest-dbg.txt"; | |
| qres /X:$Env:SUNSHINE_CLIENT_WIDTH /Y:$Env:SUNSHINE_CLIENT_HEIGHT /R:$Env:SUNSHINE_CLIENT_FPS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment