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.
JavaScript androidapple-ecosystemconnectelectronfile-sharingintel-unison-alternativeiosios-windowskde-connect-alternativekvmlinuxmacbookmacosmouse-sharingphone-link-alternativeproductivityscreen-sharingsidecar-alternativesynergy-alternativewindows
// TwinDesk — Copyright (C) 2026 inukaasith. GPL-3.0, see LICENSE.
// Two pages of TwinDesk Professional (docs/full-kvm.md), Windows and Linux, every build:
// - Login & UAC (Linux: Login & admin; id fullkvm, module fullkvm): Off, Signed in (the service: lock
// screen, UAC or polkit prompts, Ctrl+Alt+Del, admin windows) or Always (also the login screen, with a
// machine copy of this computer's pairings). Each change asks for an administrator once. Remote unlock:
// other computers (Touch ID on a Mac, Windows Hello or its PIN) unlock this one; one-to-one with Allow
// other devices, in Multi-device as mesh managers accepted here (Accept, Decline, Revoke).
// - Phone unlock (id biounlock, module phoneunlock): a phone's fingerprint or Face ID unlocks the lock
// screen and signs in at the login screen (shared/fullkvm/unlock-host.js), through Login & UAC's
// service. Only while an Android phone or an iPhone/iPad is the device in session. On Windows,
// TwinDesk's tile is the default sign-in option or one picked from Sign-in options (unlockAsk).
// Both are this computer's own: Login & UAC is hidden with a phone, tablet or TV in session.
// The Professional build's own preload (linux/fullkvm/preload.js, windows/fullkvm/preload.js) gives
// window.tdFullKvm: then the pages work. Without it (the standard build, which carries no service, agent
// or helper of these) the pages are the same, their choices shown but not usable, with a card saying
// they're in TwinDesk Professional (free) only, and the first time one opens in a run a popup offers it.
// The edition keeps a PRO pill beside the app's name. At the bottom, a picture (shared/feature-art.js).
'use strict';
(function () {
const api = window.tdFullKvm || null;
const COLOR = 'linear-gradient(#5e5ce6, #3634a3)';
const PHONE_COLOR = 'linear-gradient(#30d158, #248a3d)';
const win = /Windows/.test(navigator.userAgent);
const TITLE = win ? 'Login & UAC' : 'Login & admin';
const t = (...a) => I18n.t(...a);
let offered = false; // the Professional popup, once a run
const getPro = () => UI.api && UI.api.openLink && UI.api.openLink('releases');
const COMPUTER_KINDS = ['mac', 'hello'];
const isComputerKey = (k) => COMPUTER_KINDS.includes(k.kind);
const KIND = { fingerprint: 'Fingerprint', face: 'Face ID', touch: 'Touch ID', mac: 'Touch ID on a Mac', hello: 'Windows Hello' };
// TwinDesk Professional (this build): a PRO pill beside the name, as Multi-device's MESH (.pro-pill in the stylesheets).
if (api && !document.querySelector('.pro-pill')) {
const name = document.querySelector('.app-name');
if (name) {
const pill = document.createElement('span');
pill.className = 'pro-pill';
pill.textContent = 'PRO';
pill.title = t('TwinDesk Professional (free): Login & UAC, Phone unlock and mesh managers');
name.append(pill);
}
}
const el = (tag, cls, text) => { const e = document.createElement(tag); if (cls) e.className = cls; if (text) e.textContent = text; return e; };
// A centred dialog: title (with an optional pill), a line, a hint, and buttons; focus: which button
// (default the last). Escape is the first button.
function dialog(cls, title, line, hint, buttons, pill, focus) {
const pop = el('div', 'pair-pop mesh-pop ' + cls);
pop.setAttribute('role', 'dialog');
pop.setAttribute('aria-modal', 'true');
const box = el('div', 'pop-body');
const head = el('strong', '', title);
if (pill) head.append(' ', el('span', 'pro-pill', pill));
box.append(head, el('p', '', line), el('div', 'hint', hint));
const actions = el('div', 'banner-actions');
const close = () => { document.removeEventListener('keydown', onKey, true); pop.remove(); };
const btns = buttons.map(([label, kind, fn]) => { const b = el('button', 'btn ' + kind, label); b.onclick = () => { close(); fn(); }; return b; });
function onKey(e) { if (e.key === 'Escape') { close(); buttons[0][2](); } }
actions.append(...btns);
pop.append(box, actions);
document.addEventListener('keydown', onKey, true);
document.body.append(pop);
btns[focus == null ? btns.length - 1 : focus].focus();
}
// Before turning on what lets another device past the lock screen (Cancel first).
const risk = (title, lines, onOk, onCancel = () => {}) => dialog('', title, lines[0], lines[1], [[t('Cancel'), '', onCancel], [t('Accept the risk'), 'danger', onOk]], '', 0);
// The standard build: the first time either page opens in a run, a popup offering TwinDesk Professional
// (free and open source, installed over this one). Not now leaves the page with its card.
function offerPro(page) {
if (api || offered || !page || page.hidden || document.querySelector('.pro-offer')) return;
offered = true;
dialog('pro-offer', t('Upgrade to TwinDesk Professional (free)'),
t('TwinDesk Professional is free and open source, like every edition. It adds Login & UAC (the mouse and keyboard on the lock screen, admin prompts and the login screen), Phone unlock and mesh managers.'),
t('No account and nothing to pay. Install it over this TwinDesk: your pairings and settings stay.'),
[[t('Not now'), '', () => {}], [t('Get TwinDesk Professional (free)'), 'primary', getPro]], 'PRO');
}
function watchOffer(page) {
if (api || !page) return;
UI.onShown(page, (shown) => { if (shown) offerPro(page); });
setTimeout(() => offerPro(page), 0); // built while already shown
}
// The standard build's card at the top of each page.
const onlyCard = (what) => UI.card(t('Only in TwinDesk Professional (free)'), [
UI.row(t('This edition of TwinDesk doesn’t include {what}', { what }),
t('It needs a system service that the standard edition leaves out. Download TwinDesk Professional (free) to use it; your pairings and settings stay as they are.'),
[UI.button(t('Get TwinDesk Professional (free)'), getPro, 'small')]),
]);
// The unlock service's state and its calls, for both pages. call(fn) runs one change and redraws.
function unlockModel(redraw) {
const m = { st: null, ust: null, busy: false };
m.refresh = async () => {
if (!api) return redraw();
try { m.st = await api.state(); } catch (_) { return; }
if (m.st.mode !== 'off' && api.unlock) {
try { m.ust = await api.unlock(); } catch (_) { /* shown as before */ }
}
redraw();
};
m.call = async (fn) => {
if (m.busy || !fn) return;
m.busy = true;
redraw();
try { m.ust = await fn(); } catch (e) { m.ust = { ...m.ust, error: String(e && e.message || e) }; }
m.busy = false;
redraw();
};
// One class on: the unlock itself on first; the last class off turns it off.
m.allow = (op, on) => m.call(async () => {
let u = m.ust || {};
if (on && !u.enabled && api.unlockOn) u = await api.unlockOn(true);
u = await api[op](on);
if (!on && u.enabled && !u.allowPhones && !u.allowComputers && api.unlockOn) u = await api.unlockOn(false);
return u;
});
// The devices of one class (phone or computer) added here, Remove, and Add for one connected.
m.addRow = (cls) => {
const pick = UI.select([], () => {});
pick.el.setAttribute('aria-label', t('Device'));
const pass = UI.el('input', { type: 'password', attrs: { autocomplete: 'off', placeholder: t('Your Windows password'), 'aria-label': t('Your Windows password') } });
const err = UI.note('warn', '');
const btn = UI.button(t('Add'), async () => {
const id = pick.el.value;
if (!id || m.busy) return;
if (win && !pass.value) { err.set(t('Type your Windows password: Windows needs it to sign you in')); return; }
m.ust = { ...m.ust, busy: 'phone', error: '' };
await m.call(() => api.unlockAdd(id, win ? pass.value : undefined));
pass.value = '';
}, 'small');
const row = UI.row(cls === 'phone' ? t('Add a phone') : t('Add a computer'), '', [pick, ...(win ? [pass] : []), btn]);
const list = UI.el('div');
return {
els: [list, row, err],
paint(u) {
const keys = (u.keys || []).filter((k) => (cls === 'phone' ? !isComputerKey(k) : isComputerKey(k)));
const rows = keys.map((k) => UI.row(k.name || t('Device'), [t(KIND[k.kind] || 'Fingerprint'), k.fp ? t('key {fp}', { fp: k.fp }) : '', k.here ? t('connected') : ''].filter(Boolean).join(', '),
[UI.button(t('Remove'), () => m.call(() => api.unlockDrop(k.id)), 'small')], { literal: false }));
if (!rows.length) rows.push(UI.row(cls === 'phone' ? t('No phone yet') : t('No computer yet'), cls === 'phone'
? t('Add a connected phone: it asks for its fingerprint or Face ID once') : t('Add a connected computer: it asks for Touch ID or Windows Hello once'), []));
list.replaceChildren(...rows);
const free = (u.phones || []).filter((p) => !p.set && (p.cls || 'phone') === cls);
pick.options(free.length ? free.map((p) => ({ value: p.id, label: (p.name || t('Device')) + (p.via ? ' ' + t('(through another computer)') : '') })) : [{ value: '', label: cls === 'phone' ? t('No phone connected') : t('No computer connected') }]);
const busyText = u.busy === 'phone' ? t('Confirm on the device…') : u.busy === 'admin' ? t('Waiting for the administrator’s approval…') : '';
row.setHint(busyText || (u.on ? t('The device must be connected on this network') : t('Waiting for the {page} service', { page: t(TITLE) })));
btn.disabled = m.busy || !!u.busy || !free.length || !u.on;
err.set(u.error ? t(u.error) : '');
},
};
};
return m;
}
// ---- Login & UAC ----
UI.tab({
id: 'fullkvm',
order: 96,
bottom: true, // with Phone unlock, Multi-device, General and About: not one of the pages Arrange moves (shared/ui-arrange.js)
for: ['computer'], // this computer's own; not with a phone, a tablet or a TV in session
icon: 'fullkvm', // the icon sets (windows/ and linux/ui-kit.js, mac/control.js)
title: TITLE,
color: COLOR,
desc: 'The mouse and keyboard on the lock screen, admin prompts and the login screen.',
build(body, page) {
let busy = false;
let asked = 0;
const m = unlockModel(() => show());
const seg = UI.segmented([
{ value: 'off', label: t('Off') },
{ value: 'simple', label: t('Signed in') },
{ value: 'system', label: t('Always') },
], (mode) => choose(mode));
if (!api) for (const b of seg.el.querySelectorAll('button')) b.disabled = true;
const modeRow = UI.row(t('Where the mouse and keyboard reach'), '', [seg]);
const statusRow = UI.row(t('Service'), '', []);
const err = UI.note('warn', '');
const warn = UI.note('info', '');
// Remote unlock: computers that unlock this one. One-to-one: Allow other devices; Multi-device: the mesh
// managers that asked to unlock it (Accept, Decline) and those accepted (Revoke).
const allowSw = UI.switch((on) => (on ? risk(t('Allow other devices to unlock this computer?'), [
t('Whoever can sign in on an added computer with Touch ID, Windows Hello or its PIN can then open this computer’s lock screen without its password.'),
t('Off by default. Turn it off any time.'),
], () => m.allow('unlockComputers', true), () => allowSw.set(false)) : m.allow('unlockComputers', false)), { label: t('Allow other devices to unlock this computer remotely') });
const allowRow = UI.row(t('Allow other devices to unlock this computer remotely'), t('A Mac with Touch ID, or a PC with Windows Hello or its PIN, connected one-to-one on this network'), [allowSw]);
const mgrBox = UI.el('div');
const pcs = m.addRow('computer');
const remoteNote = UI.note('info', '');
const remoteCard = UI.card(t('Remote unlock'), [allowRow, mgrBox, ...pcs.els, remoteNote]);
if (!api) { allowSw.disable(true); mgrBox.hidden = true; for (const e of pcs.els) e.hidden = true; }
const setMgr = (o) => UI.api && UI.api.setMgr && UI.api.setMgr(o);
let mgrKey = '';
function paintMgr(u) {
const mg = (UI.state && UI.state.mgr) || {};
const asks = (mg.asks || []).filter((a) => (a.perms || []).includes('unlock'));
const grants = (mg.grants || []).filter((g) => (g.perms || []).includes('unlock'));
const k = JSON.stringify([asks, grants, m.busy]);
if (k === mgrKey) return;
mgrKey = k;
const rows = [];
for (const a of asks) {
rows.push(UI.row(t('{computer} asks to unlock this computer', { computer: a.name }), t('With Touch ID, Windows Hello or its PIN, without this computer’s password'), [
UI.button(t('Accept'), () => risk(t('Let {computer} unlock this computer?', { computer: a.name }), [
t('Whoever can sign in on {computer} with Windows Hello, its PIN or Touch ID can then open this computer’s lock screen without its password.', { computer: a.name }),
t('Then add {computer} below.', { computer: a.name }),
], () => {
setMgr({ answer: { mgr: a.id, perm: 'unlock', yes: true } });
if (!(u && u.enabled) && api.unlockOn) m.call(() => api.unlockOn(true));
}), 'small primary'),
UI.button(t('Decline'), () => setMgr({ answer: { mgr: a.id, perm: 'unlock', yes: false } }), 'small'),
], { literal: true }));
}
for (const g of grants) rows.push(UI.row(t('{computer} can unlock this computer', { computer: g.name }), t('A mesh manager you accepted'), [UI.button(t('Revoke'), () => setMgr({ revoke: g.id }), 'small')], { literal: true }));
if (!rows.length) rows.push(UI.row(t('No mesh manager has asked yet'), t('A mesh manager asks from its Multi-device page. Accept it here'), []));
mgrBox.replaceChildren(...rows);
}
watchOffer(page);
body.append(
...(api ? [] : [onlyCard(t(TITLE))]),
UI.card(t(TITLE), [modeRow, statusRow, err]),
remoteCard,
UI.card(t('What each one does'), [
UI.row(t('Off'), t('As in TwinDesk: the pointer stops at the lock screen, admin prompts and windows run as administrator'), []),
UI.row(t('Signed in'), t('A system service carries the mouse and keyboard to the lock screen, admin prompts (UAC, polkit), Ctrl+Alt+Del and windows run as administrator, while someone is signed in'), []),
UI.row(t('Always'), t('Also the login screen, after a restart or sign-out: the service keeps this computer in the mesh with a copy of its pairings, so the others can sign in on it'), []),
]),
warn,
window.FeatureArt && FeatureArt.picture ? FeatureArt.picture('fullkvm', { color: COLOR }) : '',
);
warn.set(t('Anyone paired with this computer can then approve admin prompts and type on the lock screen. Turn it on only with devices you trust.'));
const HINT = {
off: 'Not installed',
simple: 'Signed in: the lock screen, admin prompts and admin windows',
system: 'Always: the login screen too',
};
function show() {
const st = m.st || (api ? null : { mode: 'off' });
if (!st) return;
seg.set(st.mode);
if (!api) {
modeRow.setHint(t('Only in TwinDesk Professional (free)'));
statusRow.setHint(t('Not in this edition'));
allowRow.setHint(t('Only in TwinDesk Professional (free)'));
return;
}
modeRow.setHint(t(HINT[st.mode] || ''));
const parts = [];
if (busy) parts.push(t('Waiting for the administrator’s approval…'));
else if (st.mode === 'off') parts.push(t('Not installed'));
else {
parts.push(st.active ? t('Running') : t('Installed, not running'));
parts.push(st.connected ? t('this app’s mouse and keyboard go through it') : t('not connected to this app yet'));
}
statusRow.setHint(parts.join(', '));
err.set(st.error ? t(st.error) : '');
// Remote unlock needs the service.
const u = m.ust;
const svcOn = st.mode !== 'off' && !!u;
remoteNote.set(svcOn ? '' : t('Choose Signed in or Always above first: the service carries the unlock.'));
const mesh = !!(u && u.mesh);
allowRow.hidden = !svcOn || mesh;
mgrBox.hidden = !svcOn || !mesh;
const on = svcOn && !!u.enabled && (mesh || !!u.allowComputers);
for (const e of pcs.els) e.hidden = !on;
if (!svcOn) return;
allowSw.set(!!u.enabled && !!u.allowComputers);
allowSw.disable(m.busy);
if (mesh) paintMgr(u);
if (on) pcs.paint(u);
}
async function choose(mode) {
if (!api || busy || !m.st || mode === m.st.mode) return;
busy = true;
show();
try { m.st = await api.set(mode); } catch (e) { m.st = { ...m.st, error: String(e && e.message || e) }; }
busy = false;
m.refresh();
}
m.refresh();
return () => {
if (!api) return;
if (m.ust && m.ust.mesh) paintMgr(m.ust); // the asks come with the window's state
const now = Date.now();
if (now - asked > 2000 && !busy && !(page && page.hidden)) { asked = now; m.refresh(); } // the service's state isn't pushed: asked now and then
};
},
});
// ---- Phone unlock ----
UI.tab({
id: 'biounlock',
order: 97,
bottom: true,
for: ['android', 'ios'], // only with a phone or tablet in session (a TV can't)
icon: 'biounlock',
title: 'Phone unlock',
color: PHONE_COLOR,
desc: 'Unlock and sign in to this computer with the phone’s fingerprint or Face ID.',
build(body, page) {
let asked = 0;
const m = unlockModel(() => show());
const onSw = UI.switch((on) => (on ? risk(t('Turn on Phone unlock?'), [
t('A phone you add here can open this computer’s lock screen and sign in without the password. Whoever can unlock that phone with a fingerprint or Face ID can then open this computer.'),
t('Add only phones you own and keep locked. A phone unlocks only the computer it’s connected to.'),
], () => m.allow('unlockPhones', true), () => onSw.set(false)) : m.allow('unlockPhones', false)), { label: t('Phone unlock') });
const onRow = UI.row(t('Phone unlock'), t('Unlock this computer with the phone’s fingerprint or Face ID'), [onSw]);
// Windows: TwinDesk's tile the default sign-in option (it asks the phone at once), or one picked from
// Sign-in options (then it asks). Linux: the lock screen asks the phone at once, or waits for its Unlock.
const how = win ? UI.segmented([
{ value: 'default', label: t('Default sign-in option') },
{ value: 'menu', label: t('In Sign-in options') },
], (v) => m.call(api && api.unlockAsk && (() => api.unlockAsk(v === 'default')))) : null;
const askSw = win ? null : UI.switch((on) => m.call(api && api.unlockAsk && (() => api.unlockAsk(on))), { label: t('Ask the phone when the lock screen opens') });
const askRow = win
? UI.row(t('On the lock screen'), '', [how])
: UI.row(t('Ask the phone when the lock screen opens'), t('Waking the lock or login screen asks the phone by itself. Off: unlock from the phone'), [askSw]);
const phones = m.addRow('phone');
const uNote = UI.note('info', '');
const mainCard = UI.card(t('Phone unlock'), [onRow, askRow]);
const devCard = UI.card(t('Phones'), phones.els);
// Professional, but Login & UAC is off: its service carries the unlock.
const needCard = UI.card(t('Needs {page}', { page: t(TITLE) }), [
UI.row(t('Turn on {page} first', { page: t(TITLE) }), t('Phone unlock works through its system service: choose Signed in or Always there.'),
[UI.button(t('Open {page}', { page: t(TITLE) }), () => UI.go('fullkvm'), 'small primary')]),
]);
if (!api) {
onSw.disable(true);
askRow.hidden = true;
}
needCard.hidden = true;
devCard.hidden = true;
uNote.hidden = true;
watchOffer(page);
body.append(...(api ? [] : [onlyCard(t('Phone unlock'))]), needCard, mainCard, devCard, uNote);
uNote.set(win
? t('The lock screen and the login screen wait for the phone, and your password still works. Windows signs in with your password, so the service keeps it where only the system can read it. If you change your password, add the phone again.')
: t('The lock screen unlocks from the phone, and the login screen asks the phone first; your password still works. Signed in this way, the keyring stays locked until you type your password.'));
function show() {
if (!api) return;
const st = m.st;
const u = m.ust;
const svcOn = !!(st && st.mode !== 'off');
needCard.hidden = !st || svcOn;
mainCard.hidden = !svcOn;
const on = svcOn && !!u && !!u.enabled && !!u.allowPhones;
devCard.hidden = !on;
uNote.hidden = !on;
askRow.hidden = !on;
if (!svcOn || !u) return;
onSw.set(!!u.enabled && !!u.allowPhones);
onSw.disable(m.busy);
const asks = u.asks !== false;
if (how) {
how.set(asks ? 'default' : 'menu');
for (const b of how.el.querySelectorAll('button')) b.disabled = m.busy;
askRow.setHint(asks ? t('TwinDesk’s tile is chosen first and asks the phone at once') : t('Pick TwinDesk under Sign-in options, then it asks the phone. The phone’s Unlock button works either way'));
} else {
askSw.set(asks);
askSw.disable(m.busy);
}
if (on) phones.paint(u);
}
m.refresh();
return () => {
if (!api || (page && page.hidden)) return;
const now = Date.now();
if (now - asked > 2000 && !m.busy) { asked = now; m.refresh(); }
};
},
});
})();