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

uv run kvm-switch

The dashboard is served at http://localhost:4000.

Test

uv run pytest -q

Diagnostic Script

Use this to inspect connected DDC/CI monitors and current input values:

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:

[System.Environment]::SetEnvironmentVariable("KVM_DEVICE_ROLE", "tower", "User")

Laptop machine:

[System.Environment]::SetEnvironmentVariable("KVM_DEVICE_ROLE", "laptop", "User")
  1. Press Win + R
  2. Run:
shell:startup
  1. Create a shortcut in that folder pointing to:
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:

wscript.exe

Arguments:

"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.

S
Description
No description provided
Readme 145 KiB
Languages
Python 78.7%
HTML 18.9%
PowerShell 1.2%
Batchfile 0.6%
VBScript 0.6%