Files
KVM_Switch/README.md
T

117 lines
2.4 KiB
Markdown

# Internal KVM Switch
FastAPI dashboard and polling service for Alienware-only KVM switching.
## Trigger Logic
The Samsung monitor is trigger-only and uses fixed input codes:
- Tower trigger: `15`
- Laptop trigger: `19`
Each installation of this tool is for one device only. The UI lets you choose:
- this device role: `tower` or `laptop`
- this device Alienware target port:
- `DP1`
- `DP2`
- `HDMI`
The device role can also still be provided by:
- environment variable `KVM_DEVICE_ROLE`
- or `config.json` field `device_role`
Valid values are:
- `tower`
- `laptop`
Examples:
- Tower role with UI port `DP1` -> on Samsung trigger `15`, send `DDM.exe /1:WriteActiveInput DP1`
- Laptop role with UI port `DP2` -> on Samsung trigger `19`, send `DDM.exe /1:WriteActiveInput DP2`
Retry behavior:
- Only attempts switching while the Samsung screen is connected
- After each switch attempt, waits `5` seconds and rechecks
- Tries at most `3` times per Samsung-connected session
- After success, it will not try again until the Samsung screen disconnects and reconnects
## Run
```powershell
uv run kvm-switch
```
The dashboard is served at `http://localhost:4000`.
## Test
```powershell
uv run pytest -q
```
## Diagnostic Script
Use this to inspect connected DDC/CI monitors and current input values:
```powershell
uv run monitorcontrol_main.py
```
## Autostart
### Easiest option: Startup folder
You can now set the role in the UI, so this step is optional.
If you prefer a default role before opening the dashboard, set it for that Windows user:
Tower machine:
```powershell
[System.Environment]::SetEnvironmentVariable("KVM_DEVICE_ROLE", "tower", "User")
```
Laptop machine:
```powershell
[System.Environment]::SetEnvironmentVariable("KVM_DEVICE_ROLE", "laptop", "User")
```
1. Press `Win + R`
2. Run:
```text
shell:startup
```
3. Create a shortcut in that folder pointing to:
```text
C:\Users\LagoWorkStation\OneDrive\Documentos\BE-terna\Internal - KVM Switch\start_kvm_switch.cmd
```
This will start the app when you log in. It opens a console window.
### Cleaner option: Task Scheduler
Use Task Scheduler if you want it to start automatically at logon with better control.
Program/script:
```text
cmd.exe
```
Arguments:
```text
/c "C:\Users\LagoWorkStation\OneDrive\Documentos\BE-terna\Internal - KVM Switch\start_kvm_switch.cmd"
```
Set the trigger to `At log on`.