Automatic resolution switching for Sunshine game streaming on Windows.
When a Moonlight client connects, your PC switches to the client's resolution: 1080p for a laptop, 2560×1600 for a tablet. When the stream ends, the original resolution comes back, whether that's ultrawide, 4K or anything else. No more black bars or tiny text on your phone, and no more manually resetting your monitor afterwards.
Pure PowerShell, nothing to install, no admin rights needed for the switching itself.
Set-Resolution.ps1 is used as a Sunshine prep command:
| Call | What it does |
|---|---|
-FromClient |
Reads SUNSHINE_CLIENT_WIDTH, SUNSHINE_CLIENT_HEIGHT and SUNSHINE_CLIENT_FPS (set by Sunshine) and switches to that mode |
-Width 1920 -Height 1080 [-RefreshRate 60] |
Switches to a fixed mode |
-Restore |
Goes back to the mode that was active before the first switch |
-WhatIf |
Only checks whether a mode is supported (CDS_TEST), changes nothing |
Details:
- Before switching, the current mode is saved to
%LOCALAPPDATA%\sunshine-scripts\previous.json. It is only saved once, so reconnecting doesn't overwrite your real desktop resolution with the streaming one. - Every mode is tested with
CDS_TESTfirst, so an unsupported mode never leaves you with a black screen. - If the client's refresh rate isn't available (e.g. a 120 Hz client on a 60 Hz monitor), the script retries without it.
- Everything is logged to
%LOCALAPPDATA%\sunshine-scripts\log.txt.
-
Clone or download this repo to a permanent place, e.g.
C:\Tools\sunshine-scripts. -
Install the app list into Sunshine (admin PowerShell, because Sunshine lives in
Program Files):cd C:\Tools\sunshine-scripts .\Install.ps1 # copies apps.json (backup of the old one is kept) .\Install.ps1 -WithConf # also copies sunshine.conf
{{SCRIPTS}}inapps.jsonis replaced by the repo path automatically. -
Restart Sunshine.
| App | Behavior |
|---|---|
| Desktop | Client resolution, restore afterwards |
| Desktop (1080p) | Always 1920×1080, restore afterwards |
| Steam Big Picture | Client resolution + Big Picture, both undone afterwards |
sunshine.conf advertises 1920x1080 and 1280x720 to clients. Adjust it to the resolutions your devices use.
In the Sunshine web UI → Applications → Command Preparations:
Do: powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File "C:\Tools\sunshine-scripts\Set-Resolution.ps1" -FromClient
Undo: powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File "C:\Tools\sunshine-scripts\Set-Resolution.ps1" -Restore
set_1080p.ps1 and set_ultrawide.ps1 are small examples of fixed presets.
- Changes the primary display only.
- If your monitor doesn't support the client's resolution, nothing is changed. Create a custom resolution in your GPU driver (NVIDIA/AMD control panel) or use a virtual display driver.
MIT © 2026 Paul Hohmann
Wenn sich ein Moonlight-Gerät verbindet, schaltet der PC auf dessen Auflösung um. Nach dem Stream stellt er die vorherige Auflösung wieder her. Einrichten: Repo an einen festen Ort legen, Install.ps1 als Admin ausführen und Sunshine neu starten. Mit -WhatIf kannst du gefahrlos prüfen, ob ein Modus unterstützt wird.