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.
// Which pages belong to which kind of device (Mac, PC and Linux windows, both modes). Loaded right
// after the UI kit (ui-kit.js / control.js) and before the pages.
// UI.deviceKind(s): the device in session: 'android', 'ios' (an iPhone or iPad), 'tv' (TwinDesk TV:
// an Android TV that says caps 'tv' in phone.info, android-tv/) or 'computer' (also with nothing
// connected: the computer pages are this computer's own settings then).
// A TV takes only the screen, the sound, files and the cursor and keyboard: a page without `for`
// is shown for it only when it is one of TV_PAGES (this computer's own settings and those features).
// A page's `for: ['computer', 'android', 'ios']`: the kinds it is for (left out: every kind). Its
// own hidden(s) still applies on top.
// A page's `variantOf: 'overview'`: its kind's own version of that page. It takes the same place
// in the sidebar (the shells' order and group, UI.baseOf) and the same introduction
// (shared/feature-art.js). Asking for any page of a family (UI.pick) gives the one for the
// device in session, so 'overview' from the tray, a popup, a saved tab or another page opens
// an iPhone's own Overview while an iPhone is connected.
// TwinDesk Web devices have their own pages the same way (shared/ui-web.js, def.web).
'use strict';
(function () {
UI.DEVICE_KINDS = ['computer', 'android', 'ios', 'tv'];
// TVs seen here (their ids), so a TV keeps its icon in the lists after it disconnects.
let tvIds;
try { tvIds = new Set(JSON.parse(localStorage.getItem('td.tvIds') || '[]').filter((x) => typeof x === 'string').slice(0, 50)); } catch { tvIds = new Set(); }
const rememberTv = (id) => {
if (!id || tvIds.has(id)) return;
tvIds.add(id);
try { localStorage.setItem('td.tvIds', JSON.stringify([...tvIds].slice(-50))); } catch {}
};
UI.isTv = (s) => {
const tv = !!(UI.isPhone && UI.isPhone(s) && s.phone && s.phone.info && Array.isArray(s.phone.info.caps) && s.phone.info.caps.includes('tv'));
if (tv) rememberTv((s.phone.connected && s.phone.connected.id) || (s.client && s.client.id) || (s.session && s.session.id) || (s.peerSession && s.peerSession.id));
return tv;
};
// A device's os for its icon and label: 'tv' for a TwinDesk TV (its beacon's tv, or one seen here), else its own.
UI.osOf = (d) => (d && (d.tv || (d.id && tvIds.has(d.id)) || (d.deviceId && tvIds.has(d.deviceId))) ? 'tv' : d ? d.os : '');
UI.deviceKind = (s) => (UI.isIphone && UI.isIphone(s) ? 'ios' : UI.isTv(s) ? 'tv' : UI.isPhone && UI.isPhone(s) ? 'android' : 'computer');
const TV_PAGES = ['connection', 'phone', 'share', 'pc-mac', 'audio', 'files', 'cursor', 'keyboard', 'general', 'about', 'multi', 'debug'];
UI.TV_PAGES = TV_PAGES;
UI.baseOf = (def) => (def ? def.variantOf || def.id : '');
const register = UI.tab;
UI.tab = function (def) {
const own = def.hidden;
if (Array.isArray(def.for)) {
def.hidden = (s) => !def.for.includes(UI.deviceKind(s)) || !!(own && own(s));
} else if (!def.web) {
def.hidden = (s) => (UI.deviceKind(s) === 'tv' && !TV_PAGES.includes(def.id)) || !!(own && own(s));
}
return register.call(UI, def);
};
// The page of id's family that is shown for s: id itself when it is, else a sibling that is.
UI.pick = (id, s = UI.state) => {
const def = UI.tabs.find((d) => d.id === id);
if (!def || !s) return id;
const base = UI.baseOf(def);
const shown = (d) => !(d.hidden && d.hidden(s));
if (shown(def)) return id;
const sibling = UI.tabs.find((d) => d !== def && UI.baseOf(d) === base && shown(d));
return sibling ? sibling.id : id;
};
})();