# 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 /MNT:AW3423DWF /WriteActiveInput DP1` - Laptop role with UI port `DP2` -> on Samsung trigger `19`, send `DDM.exe /MNT:AW3423DWF /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_background.vbs ``` This starts the app at logon in the background (no persistent console window). ### Cleaner option: Task Scheduler Use Task Scheduler if you want it to start automatically at logon with better control. Program/script: ```text wscript.exe ``` Arguments: ```text "C:\Users\LagoWorkStation\OneDrive\Documentos\BE-terna\Internal - KVM Switch\start_kvm_switch_background.vbs" ``` Set the trigger to `At log on`. Optional: enable `Hidden` in task settings.