Skip to content

All your computers and your phone/iPhone, working as one desk. Screens, apps, files, clipboard, calls, texts, notifications, mouse and keyboard, shared between Mac, Windows, Linux , Android, Web and ios / ipados . Free and open source. No account, no cloud, and no shared network needed.

16.1 KB
Raw Blame

Full KVM: the service (Windows, Linux)

Branch twindesk-full-kvm-v3.1.1. The mouse and keyboard of the mesh reach everything on a Windows or Linux computer: UAC prompts, the lock screen, Ctrl+Alt+Del, windows run as administrator, polkit dialogs, and (System-wide) the login screen after a restart or sign-out. Chosen on the Login & UAC page (Login & admin on Linux, which has no UAC); Biometric unlock has its own Biometric unlock page.

The edition is shown as TwinDesk Professional (free), with a PRO pill next to the app's name. About › Editions (shared/ui-editions.js) lists every edition of the platform, says which one this copy is, and that all of them are free and open source. Only a TwinDesk Professional computer can be unlocked with Biometric unlock, from a phone connected to it or from a mesh manager it accepted (mesh.md); a TwinDesk Professional computer can also be a mesh manager itself, as any Mac can.

The pages in every build

shared/ui-fullkvm.js is two pages on Windows and Linux in every build: Login & UAC (id fullkvm) and Biometric unlock (id biounlock; it asks to turn Login & UAC on first, as its service carries the unlock). On Windows, Biometric unlock's On the lock screen picks whether TwinDesk's tile is the Default sign-in option (it asks the phone at once) or one picked In Sign-in options (then it asks); unlockAsk, off by default: the phone is asked only when its Unlock is pressed (or the tile picked). In the standard build, the first time either page opens in a run, a popup offers TwinDesk Professional (free). Login & UAC has a picture of it at work at the bottom (FeatureArt.picture('fullkvm'), shared/feature-art.js). The Full KVM build's preload gives it window.tdFullKvm and the choice works. The normal build has no preload, service, agent or helper of Full KVM (shared/fullkvm/ and the platform's fullkvm/ aren't in it): the tab shows the same choice, unusable, under a card saying it's only in the Full KVM builds, with a link to them.

It's a module (Settings › General › Modules › Login & UAC, both pages). Off, the page isn't loaded and the app doesn't connect to the service (shared/edition.js moduleOff, read before the helper is made). A service that is installed stays installed: Off / Signed in / Always is changed on the tab, before switching it off.

Why the app alone can't

  • Windows. The helper runs as the signed-in user. A UAC prompt, the lock screen and Ctrl+Alt+Del are on the secure desktop (winsta0\Winlogon), which no user process may open: Native.SecureDesktop() sees it and the pointer stops. Windows run as administrator refuse its injected input (UIPI). Nobody signed in: no TwinDesk at all.
  • Linux. X11 lock screens take XTest input already; Wayland's helper needs /dev/uinput (the setgid copy, #144). The greeter (GDM, SDDM, LightDM) runs as its own user before anyone signs in: no TwinDesk there.

The two modes

Off Simple System-wide
Lock screen, UAC, Ctrl+Alt+Del, admin windows no yes yes
Login screen (nobody signed in) no no yes
Pairing per user per user per user, plus a machine copy
Installs nothing the service the service and the machine node

Both need an administrator once (UAC on Windows, pkexec on Linux), from the tab's button. On NixOS the service is declared instead (programs.twindesk.fullKvm, nix/fullkvm.nix, docs/nixos.md) and the tab shows it.

The pieces

            signed in                                  nobody signed in (System-wide)
  TwinDesk app (user) ──kvm pipe──▶ service ◀──kvm pipe── machine node (unprivileged account)
     helper: clipboard, windows…      │                     mesh core headless: link, pairing,
                                      ▼                     layout, kvm (driven and driving)
                          the KVM helper, privileged,
                          on the input desktop / evdev+uinput
  • The KVM helper in the service. The same helper binary, privileged:
    • Windows: macshare-winhelper-agent.exe --agent (the multi helper's sources built with FULLKVM, windows-helper/src/Agent.cs), started by the service (LocalSystem) in the console session with a SYSTEM token. A thread with hooks can't change desktops, so an agent belongs to the input desktop it started on (Default, Winlogon, Screen-saver); when that changes it exits with code 3 and the service starts another there, giving it the last kvmConfig, armReturn and capture again: the app never sees the switch. Ctrl+Alt+Del becomes SendSAS in the service (the policy SoftwareSASGeneration = 1 is set while Full KVM is on, and put back after).
    • Linux: macshare-linuxhelper-multi with MACSHARE_HELPER_BACKEND=uinput, as root: evdev capture and uinput injection, below every display server, so it works the same at the lock screen and greeter.
  • The kvm pipe. JSON lines, the helper's own protocol, for the KVM commands only (kvmConfig, screens, capture, place, armReturn, inject, releaseAll, watchRelease, moveTo, info, ping, and on Windows dragCross, dragHold): anything else (files, clipboard, windows) is refused, so the privileged side never reads a file or runs anything for its client. Who may connect:
    • Windows: \\.\pipe\TwinDesk.kvm, its ACL the console session's user (or LOCAL SERVICE, the machine node, while nobody is signed in), network logons denied; the service checks the client's image is the TwinDesk.exe the administrator turned it on for (%ProgramData%\TwinDesk\fullkvm.json, administrators and SYSTEM only).
    • Linux: /run/twindesk/kvm.sock, owned by the active seat0 user (or twindesk at the greeter), mode 0600; a new owner drops the old connection.
  • The app. With the service there, shared/fullkvm/route.js (wrapping linux/helper.js, windows/helper.js) sends the KVM commands down the pipe and takes the KVM events from it; everything else stays with its own helper. No service: as before.
  • File drags past the edge (Windows). The strip that catches an Explorer drag at the edge (windows-helper/src/DropEdge.cs) is the app's own helper's, not the agent's: Windows doesn't let a program of the user's drop onto a window of SYSTEM's, so on the agent's strip a drag stopped at the edge (and the agent's capture doesn't cross with a button held). route.js tells the app's helper what the agent's capture does (dragStrip: the sides, the way back, capturing), and a drag caught there comes back as dragCross / dragHold, which it sends down the pipe: the agent's capture crosses with the files (DragRelay.cs). The agent shows no strip.
  • The machine node (System-wide). The mesh core without Electron's windows (electron stubbed: app.getPath is the machine folder), started by the service while nobody is signed in and stopped when someone is (their app takes over the same port). It runs as an unprivileged account (Linux twindesk, Windows LOCAL SERVICE in the TwinDeskFullKvmNode service), never as root/SYSTEM: the network-facing part has no privileges, the injecting part has no network.
    • Its identity is the user's: turning System-wide on copies the certificate, device id and the pairings (identity/, device.json, paired*.json, pairing*.json, the layout) to the machine folder (/var/lib/twindesk, %ProgramData%\TwinDesk\machine, readable by the service accounts and administrators only). The other devices see the same device, at the same place on the map.
    • It is shared/fullkvm/headless.js, the same on both (the platform's own mesh modules).
    • The person's TwinDesk gives way while seat0 isn't theirs (Linux, linux/fullkvm/manager.js): on X11 an app in a session off screen stalls on the display and can't notice, yet holds the discovery port, the server port and the links. A guard (sh, its own systemd-run --user unit) ends it after 3 s and starts it again when the session is back. To do on Windows: a disconnected session's TwinDesk keeps running and holds the ports the same way.
    • On Windows the app stages the copy in its own temp folder, with the certificate's passphrase unsealed (DPAPI is the user's; LOCAL SERVICE couldn't open it) and its displays (fullkvm-displays.json); --apply copies it and the app deletes the stage.
    • Pairing changes made later (pairing again, forgetting, the map): on Windows, before the node starts at the login screen, the service copies the pairing files (paired*.json, pairing*.json, multi.json, settings.json) again from the TwinDesk of whoever was just signed in, only when its device.json has the machine copy's id, and only plain files they (or administrators) own: no links or junctions, 1 MB at most. The certificate isn't copied again. On Linux, the next time System-wide is turned on (to do).
    • The node never writes or removes the pairing files (headless.js pairStore): nobody can pair at the login screen, so a host's bad_token (it was paired again meanwhile) mustn't forget it for good.
    • Windows, signing in: the node stops, and the service starts the person's TwinDesk 2 s later (the command of its Run entry, if Start with Windows is on and Task Manager's Startup apps hasn't turned it off) rather than waiting for Windows' startup apps, minutes on a busy computer with nothing of TwinDesk meanwhile. Windows' own start later finds it running (--hidden: the window stays closed).
    • Windows, General › Keep the display awake › Always: while the person's TwinDesk isn't running (the login screen, the moments after signing in) the service holds the computer and its display awake (a power request), from their settings.json (nobody signed in yet: the machine copy's).

Biometric unlock

Part of the Full KVM service, Windows and Linux, off by default (Full KVM › Biometric unlock). A phone's fingerprint (Android), Face ID or Touch ID (iPhone, iPad), or another computer's Touch ID (Mac) or Windows Hello (PC) unlocks this computer's lock screen and, in Always, its login screen.

Who may unlock:

  • Allow phones (on) and Allow computers (off), on the computer that's unlocked.
  • On the device that unlocks: General › Biometric unlock on a phone, Unlock other computers on a Mac or PC (Overview in one-to-one, the Mesh manager tab in Multi-device). Both off on a new install.
  • In Multi-device, a computer must also be a mesh manager with the Unlock permission (Multi-device › Mesh managers, mesh.md). A phone connected to another computer of the mesh reaches this one through it (shared/unlock-via.js), only when both links are this network.

The keys:

  • Each unlocking device makes a key for each computer, usable only right after its own biometric: Android Keystore P-256 (StrongBox when there is one, per use, gone with a new fingerprint), iOS and Mac Secure Enclave P-256 (.biometryCurrentSet), Windows Hello RSA-2048 (KeyCredentialManager, TPM).
  • Add a device (Full KVM tab): the device signs a nonce with its new key; the service keeps the public half (Linux /etc/twindesk/unlock/<uid>.keys, Windows %ProgramData%\TwinDesk\unlock.json, root or SYSTEM only), after one administrator prompt. Both screens show the key's fingerprint (16 hex digits of SHA-256 of the public key) to compare.
  • To unlock, the service makes a one-time nonce (60 s) and checks the signature of "twindesk-unlock-v1\n" + user + "\n" + nonce itself (shared/fullkvm/unlock.js, Unlock.cs). The app in between only passes messages on.
  • Windows signs in with the person's password: the service keeps it encrypted (AES-256-CBC with HMAC-SHA256) under a key K that only the unlocking device holds, wrapped by a key of its own behind its biometric (Android AES-GCM Keystore key, iOS and Mac Secure Enclave key agreement). Each unlock sends the wrapped K out and K comes back beside the signature, so the PC's disk alone opens nothing. A Windows PC that unlocks keeps K with DPAPI and sends it only after Windows Hello signed.

Without extra clicks:

  • Ask the phone when the lock screen opens (on): waking the lock or login screen asks the device by itself. On Windows, TwinDesk's tile is then the default sign-in option and signs in by itself once the phone says yes; the password and PIN stay under Sign-in options. Off: unlock from the device (Overview › Unlock, or the notification when the computer locks).
  • Linux: pam_twindesk.so (auth sufficient, before common-auth, in gdm-password, lightdm and sddm, added with the first device and removed with the last) asks the service over /run/twindesk/unlock.sock (root only) and shows "Confirm on "; anything but a yes falls through to the password. The device's own Unlock uses loginctl unlock-session; at the login screen it leaves a 30 s approval that the next PAM ask takes.
  • Windows: TwinDeskUnlock.dll, a credential provider, asks the service over \\.\pipe\TwinDesk.unlock (SYSTEM only; the server must be twindesk-fullkvm.exe beside it) and never blocks LogonUI.

Limits:

  • Only this network, the USB cable or Bluetooth: never a tailnet, the internet or the relay.
  • Five failures in 15 minutes lock it for 15 minutes; after a no, the password for 60 s. Each device also refuses a computer's asks for 10 minutes after three no's.
  • The prompt names the computer as the device knows it (its pairing or its mesh), never as a request says.
  • Windows refusing the password (it was changed): the service forgets it and says to add the device again.

Security

  • Off by default; each mode is the person's choice, with an administrator's approval.
  • The privileged process takes input events only, from a client the OS vouches for (ACL, file mode), and never from the network.
  • Approving a UAC prompt by remote input is what this is for: anyone paired with this computer can then do it. The tab says so.
  • The machine copy of the pairing is as sensitive as the user's: same file modes, removed when System-wide is turned off or TwinDesk is uninstalled.

Steps

  1. Biometric unlock (phase 6 of the 2026-11-28 plan): the PAM module (tested on Ubuntu 24.04 with linux/fullkvm/test/pam-e2e.sh), the credential provider (windows/fullkvm/unlock/, built by build.cmd with Visual C++), phones and computers that unlock.
  2. Linux service and Simple mode (testable in the Ubuntu VM): linux/fullkvm/, the pipe, mesh/helper.js.
  3. The Full KVM tab (Linux, Windows): mode, status, install/remove.
  4. Linux System-wide: the machine node, twindesk account, GDM greeter test in the VM.
  5. Windows service, agent (desktop following, SendSAS), named pipe, installer hooks. Not built here: the user's Windows CI.

Windows files

  • windows/fullkvm/service/Service.cs → windows/fullkvm/bin/twindesk-fullkvm.exe (build.cmd, C# 5): the TwinDeskFullKvm service, the TwinDeskFullKvmNode service (--node), and the setup the tab runs (--setup asks for UAC and runs --apply elevated: CreateService, no PowerShell, no sc.exe). --state for the tab, --stop/--start for the installer around an update.
  • windows-helper/build.cmd with TWINDESK_EDITION=full-kvm also builds the agent and calls windows/fullkvm/build.cmd; windows/installer/build.js with it names the installer TwinDesk-FullKVM-Setup-… and uses installer-fullkvm.nsh (stop/start the service around an update, --apply off on uninstall). No Store package for this build.
  • windows/fullkvm/manager.js, preload.js: the tab's state and modes (as Linux's).
  • At the login screen (nobody signed in) the first agent starts on Default and moves to Winlogon before it's ready: the service passes the client the first ready from whichever agent says it, and only after that keeps a new agent's ready to itself (replaying the settings to it).
  • A dev checkout: the service runs twindesk-fullkvm.exe from the checkout as SYSTEM, so use it on a test machine only (installed, it lives under Program Files, which only administrators can change).
  1. Multi-device test with the Mac and the Ubuntu VM: lock screen, polkit prompt, greeter.