mirror of
https://github.com/Andre-Bzk/SunshineDisplaySwitch.git
synced 2026-11-15 09:33:11 +01:00
refactor: replace PowerShell scripts with simple batch files (Overengineering)
This commit is contained in:
@@ -0,0 +1 @@
|
||||
CLAUDE.md
|
||||
@@ -1,62 +1,109 @@
|
||||
# SunshineDisplaySwitch
|
||||
|
||||
Löst ein Problem beim Game-Streaming mit **Sunshine + Moonlight**: Der physische PC-Monitor soll während des Streams deaktiviert sein und danach zuverlässig wieder aktiviert werden.
|
||||
[English](#english) | [Deutsch](#deutsch)
|
||||
|
||||
## Hintergrund
|
||||
---
|
||||
|
||||
Sunshine läuft als Windows-Dienst (Session 0 / SYSTEM-Kontext). `DisplaySwitch.exe /internal` hat aus diesem Kontext zwar keinen Fehler geworfen, aber keinen Effekt gehabt — das Reaktivieren eines deaktivierten Monitors erfordert die interaktive Benutzersession. Die Lösung nutzt den Task Scheduler mit `InteractiveToken`, um den Befehl garantiert in der richtigen Session auszuführen.
|
||||
## English
|
||||
|
||||
## Dateien
|
||||
Solves a problem with game streaming via **Sunshine + Moonlight**: The physical PC monitor is disabled during the stream and reliably reactivated afterwards.
|
||||
|
||||
### Files
|
||||
|
||||
| File | Purpose |
|
||||
|---|---|
|
||||
| `idd_an.bat` | Sunshine Do-Command — enables IDD virtual monitor, disables physical monitor |
|
||||
| `idd_aus.bat` | Sunshine Undo-Command — reactivates physical monitor |
|
||||
| `register_task.bat` | Run once — registers a logon task as fallback if the PC is shut down during a stream |
|
||||
|
||||
### Setup
|
||||
|
||||
#### 1. Configure Sunshine
|
||||
|
||||
In the Sunshine web UI under **Configuration > General**:
|
||||
|
||||
| Field | Value |
|
||||
|---|---|
|
||||
| Command Preparations — Do | `C:\Projekte\SunshineDisplaySwitch\idd_an.bat` |
|
||||
| Command Preparations — Undo | `C:\Projekte\SunshineDisplaySwitch\idd_aus.bat` |
|
||||
|
||||
#### 2. Register fallback task (once)
|
||||
|
||||
Run `register_task.bat` as administrator. Registers `DisplaySwitch /internal` as a logon task (`MoonlightTeardown`). This activates if the PC is shut down during a stream and the physical monitor is still disabled on next boot.
|
||||
|
||||
### How it works
|
||||
|
||||
```
|
||||
Stream starts
|
||||
└─> idd_an.bat
|
||||
└─> DisplaySwitch.exe /external (IDD active, physical monitor off)
|
||||
|
||||
Stream ends
|
||||
└─> idd_aus.bat
|
||||
├─> DisplaySwitch.exe /extend (both displays in topology)
|
||||
├─> 4 second wait
|
||||
└─> DisplaySwitch.exe /internal (IDD removed, physical monitor stays)
|
||||
```
|
||||
|
||||
#### Why /extend before /internal?
|
||||
|
||||
After `DisplaySwitch /external`, the physical monitor is removed from the Windows display topology. A direct `DisplaySwitch /internal` cannot bring it back — Windows no longer sees it. `/extend` restores both monitors into the topology, then `/internal` removes the IDD monitor again.
|
||||
|
||||
### Requirements
|
||||
|
||||
- Windows 10/11
|
||||
- [Sunshine](https://github.com/LizardByte/Sunshine) as streaming server
|
||||
- [IDD (Indirect Display Driver)](https://github.com/itsmikethetech/Virtual-Display-Driver) as virtual monitor
|
||||
|
||||
---
|
||||
|
||||
## Deutsch
|
||||
|
||||
Löst ein Problem beim Game-Streaming mit **Sunshine + Moonlight**: Der physische PC-Monitor wird während des Streams deaktiviert und danach zuverlässig wieder aktiviert.
|
||||
|
||||
### Dateien
|
||||
|
||||
| Datei | Zweck |
|
||||
|---|---|
|
||||
| `register_task.bat` | Einmalige Einrichtung — registriert den Scheduled Task |
|
||||
| `idd_an.bat` | Sunshine Preparation Command — schaltet auf virtuellen Monitor um |
|
||||
| `idd_aus.bat` | Sunshine Teardown Command — reaktiviert den physischen Monitor |
|
||||
| `idd_an.bat` | Sunshine Do-Command — aktiviert virtuellen IDD-Monitor, deaktiviert physischen Monitor |
|
||||
| `idd_aus.bat` | Sunshine Undo-Command — reaktiviert physischen Monitor |
|
||||
| `register_task.bat` | Einmalig ausführen — registriert Logon-Task als Fallback nach Shutdown während Stream |
|
||||
|
||||
## Einrichtung
|
||||
### Einrichtung
|
||||
|
||||
### 1. Task registrieren (einmalig)
|
||||
|
||||
`register_task.bat` per Doppelklick ausführen und den UAC-Dialog bestätigen. Der Task `MoonlightTeardown` wird in der Windows-Aufgabenplanung registriert.
|
||||
|
||||
Zur Kontrolle:
|
||||
```
|
||||
schtasks /query /tn MoonlightTeardown /fo list /v
|
||||
```
|
||||
|
||||
Unter `Trigger` sollten zwei Einträge erscheinen: `At log on` (Fallback nach Shutdown) und der Task ist zusätzlich jederzeit manuell aufrufbar — beide Mechanismen nutzen dieselbe Aktion.
|
||||
|
||||
### 2. Sunshine konfigurieren
|
||||
#### 1. Sunshine konfigurieren
|
||||
|
||||
In der Sunshine Web-UI unter **Configuration > General**:
|
||||
|
||||
| Feld | Wert |
|
||||
|---|---|
|
||||
| Command Preparations — Do | Pfad zu `idd_an.bat` |
|
||||
| Command Preparations — Undo | Pfad zu `idd_aus.bat` |
|
||||
| Command Preparations — Do | `C:\Projekte\SunshineDisplaySwitch\idd_an.bat` |
|
||||
| Command Preparations — Undo | `C:\Projekte\SunshineDisplaySwitch\idd_aus.bat` |
|
||||
|
||||
## Funktionsweise
|
||||
#### 2. Fallback-Task registrieren (einmalig)
|
||||
|
||||
`register_task.bat` als Administrator ausführen. Registriert `DisplaySwitch /internal` als Logon-Task (`MoonlightTeardown`). Greift, falls der PC während eines Streams heruntergefahren wird und der physische Monitor beim nächsten Start noch deaktiviert ist.
|
||||
|
||||
### Funktionsweise
|
||||
|
||||
```
|
||||
Stream startet
|
||||
└─> idd_an.bat
|
||||
└─> DisplaySwitch.exe /external (virtuellen Monitor aktivieren)
|
||||
└─> DisplaySwitch.exe /external (IDD aktiv, physischer Monitor aus)
|
||||
|
||||
Stream endet (normal)
|
||||
└─> idd_aus.bat [läuft in Session 0]
|
||||
└─> Start-ScheduledTask 'MoonlightTeardown'
|
||||
└─> Task Scheduler [InteractiveToken = Benutzersession]
|
||||
└─> DisplaySwitch.exe /internal (physischen Monitor reaktivieren)
|
||||
|
||||
Stream endet durch Shutdown (Fallback)
|
||||
└─> PC bootet neu → User-Login
|
||||
└─> MoonlightTeardown [Logon-Trigger]
|
||||
└─> DisplaySwitch.exe /internal (physischen Monitor reaktivieren)
|
||||
Stream endet
|
||||
└─> idd_aus.bat
|
||||
├─> DisplaySwitch.exe /extend (beide Displays in Topologie)
|
||||
├─> 4 Sekunden warten
|
||||
└─> DisplaySwitch.exe /internal (IDD entfernt, physischer Monitor bleibt)
|
||||
```
|
||||
|
||||
## Voraussetzungen
|
||||
#### Warum /extend vor /internal?
|
||||
|
||||
Nach `DisplaySwitch /external` wird der physische Monitor aus der Windows Display-Topologie entfernt. Ein direktes `DisplaySwitch /internal` würde ihn nicht zurückholen — er ist für Windows nicht mehr sichtbar. `/extend` bringt beide Monitore zurück in die Topologie, danach entfernt `/internal` den IDD-Monitor wieder.
|
||||
|
||||
### Voraussetzungen
|
||||
|
||||
- Windows 10/11
|
||||
- [Sunshine](https://github.com/LizardByte/Sunshine) als Streaming-Server
|
||||
- Kein zusätzliches Tool erforderlich — nur Windows-Bordmittel
|
||||
- [IDD (Indirect Display Driver)](https://github.com/itsmikethetech/Virtual-Display-Driver) als virtueller Monitor
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
@echo off
|
||||
DisplaySwitch.exe /external
|
||||
timeout /t 2
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
@echo off
|
||||
REM Sunshine laeuft in Session 0 — DisplaySwitch muss in der User-Session laufen.
|
||||
REM Task Scheduler startet es mit InteractiveToken in der richtigen Session.
|
||||
powershell.exe -NonInteractive -Command "Start-ScheduledTask -TaskName 'MoonlightTeardown'"
|
||||
DisplaySwitch /extend
|
||||
timeout /t 4
|
||||
DisplaySwitch /internal
|
||||
Reference in New Issue
Block a user