Skip to content

Instantly share code, notes, and snippets.

@espeon
Last active September 25, 2024 16:53
Show Gist options
  • Select an option

  • Save espeon/221454a358019d4422eca78ecff103d3 to your computer and use it in GitHub Desktop.

Select an option

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"`
$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
$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