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.
// Writes android/app/src/main/java/com/twindesk/android/DeckCatalog.kt from the computer's own
// shared/deck-catalog.js (the actions' groups, names and descriptions) and shared/deck-icons.js
// (the symbols), so the phone's Deck says and draws exactly what the computer's Deck page does.
// Run: node android/tools/gen-deck.js (shared/test/deck-android.js checks it's up to date)
'use strict';
const fs = require('fs');
const path = require('path');
const C = require('../../shared/deck-catalog.js');
const I = require('../../shared/deck-icons.js');
const OUT = path.join(__dirname, '..', 'app', 'src', 'main', 'java', 'com', 'twindesk', 'android', 'DeckCatalog.kt');
const q = (s) => JSON.stringify(String(s)).replace(/\$/g, '\\$');
const text = (v) => (v && typeof v === 'object' ? `mapOf(${Object.entries(v).map(([k, x]) => `${q(k)} to ${q(x)}`).join(', ')})` : `mapOf("" to ${q(v)})`);
function make() {
const lines = [];
lines.push('// TwinDesk — Copyright (C) 2026 inukaasith. GPL-3.0, see LICENSE.');
lines.push('// Generated by android/tools/gen-deck.js from shared/deck-catalog.js and shared/deck-icons.js: don’t edit.');
lines.push('// The Deck’s actions as people choose them, and its symbols, the same as on the computer’s Deck page.');
lines.push('package com.twindesk.android');
lines.push('');
lines.push('import androidx.compose.ui.graphics.Color');
lines.push('import androidx.compose.ui.graphics.SolidColor');
lines.push('import androidx.compose.ui.graphics.StrokeCap');
lines.push('import androidx.compose.ui.graphics.StrokeJoin');
lines.push('import androidx.compose.ui.graphics.vector.ImageVector');
lines.push('import androidx.compose.ui.graphics.vector.PathParser');
lines.push('import androidx.compose.ui.unit.dp');
lines.push('import org.json.JSONObject');
lines.push('');
lines.push('object DeckCatalog {');
lines.push(' // name and desc by the computer’s platform ("" = every one); needs: a caps key that must be true.');
lines.push(' class Entry(val id: String, val group: String, val name: Map<String, String>, val desc: Map<String, String>, val action: String,');
lines.push(' val needs: String, val local: Boolean, val device: Boolean, val wide: Boolean) {');
lines.push(' fun name(platform: String) = name[platform] ?: name[""] ?: name["mac"] ?: ""');
lines.push(' fun desc(platform: String) = desc[platform] ?: desc[""] ?: desc["mac"] ?: ""');
lines.push(' fun action() = JSONObject(action)');
lines.push(' val k: String get() = JSONObject(action).optString("k")');
lines.push(' val what: String? get() = JSONObject(action).optString("what").ifEmpty { null }');
lines.push(' }');
lines.push(` val GROUPS = listOf(${C.GROUPS.map((g) => `${q(g.id)} to ${q(g.name)}`).join(', ')})`);
lines.push(' val ENTRIES = listOf(');
for (const e of C.ENTRIES) {
lines.push(` Entry(${q(e.id)}, ${q(e.group)}, ${text(e.name)}, ${text(e.desc)}, ${q(JSON.stringify(e.action))}, ${q(e.needs || '')}, ${!!e.local}, ${!!e.device}, ${!!e.wide}),`);
}
lines.push(' )');
lines.push(' // The entry an action came from (its kind, and its step when the entry has one).');
lines.push(' fun entry(a: JSONObject?): Entry? {');
lines.push(' if (a == null) return null');
lines.push(' val k = a.optString("k")');
lines.push(' return ENTRIES.firstOrNull { it.k == k && (it.what == null || it.what == a.optString("what")) }');
lines.push(' }');
lines.push(' fun available(e: Entry, caps: JSONObject?, platform: String): String? {');
lines.push(' if (e.needs.isEmpty() || caps?.optBoolean(e.needs, true) != false) return null');
lines.push(' return when {');
lines.push(' platform == "linux" && e.needs == "screenoff" -> "Not on Linux"');
lines.push(' platform == "linux" && e.needs == "windows" -> "Not on Wayland"');
lines.push(' platform == "mac" && e.needs == "dnd" -> "macOS has no switch for apps"');
lines.push(' else -> "Not on this computer"');
lines.push(' }');
lines.push(' }');
lines.push('');
lines.push(' private fun icon(name: String, d: String, filled: Boolean): ImageVector = ImageVector.Builder(name, 24.dp, 24.dp, 24f, 24f).apply {');
lines.push(' addPath(pathData = PathParser().parsePathString(d).toNodes(), fill = if (filled) SolidColor(Color.Black) else null, stroke = SolidColor(Color.Black),');
lines.push(' strokeLineWidth = 1.8f, strokeLineCap = StrokeCap.Round, strokeLineJoin = StrokeJoin.Round)');
lines.push(' }.build()');
lines.push(' private val PATHS = mapOf(');
for (const [k, d] of Object.entries(I.PATHS)) lines.push(` ${q(k)} to ${q(d)},`);
lines.push(' )');
lines.push(' private val cache = HashMap<String, ImageVector>()');
lines.push(' // A symbol (shared/deck-model.js SYMBOLS) as an icon; null when it isn’t one (an emoji).');
lines.push(' fun symbol(name: String): ImageVector? {');
lines.push(' val d = PATHS[name] ?: return null');
lines.push(' return cache.getOrPut(name) { icon(name, d, name == "play" || name == "stop") }');
lines.push(' }');
lines.push(` val SYMBOLS = listOf(${Object.keys(I.PATHS).filter((k) => k !== 'none').map(q).join(', ')})`);
lines.push('');
lines.push(' // The symbol a tile shows when it has none of its own (shared/deck-model.js symbolOf).');
lines.push(' fun symbolOf(a: JSONObject?): String {');
lines.push(' val w = a?.optString("what") ?: ""');
lines.push(' return when (a?.optString("k")) {');
const M = require('../../shared/deck-model.js');
for (const k of M.KINDS) {
const whats = M.WHATS[k];
if (!whats) { lines.push(` ${q(k)} -> ${q(M.symbolOf({ k }) || 'none')}`); continue; }
lines.push(` ${q(k)} -> when (w) { ${whats.map((w) => `${q(w)} -> ${q(M.symbolOf({ k, what: w }) || 'none')}`).join('; ')}; else -> ${q(M.symbolOf({ k, what: whats[0] }) || 'none')} }`);
}
lines.push(' else -> "none"');
lines.push(' }');
lines.push(' }');
lines.push('}');
return lines.join('\n') + '\n';
}
if (require.main === module) {
fs.writeFileSync(OUT, make());
console.log('wrote ' + path.relative(process.cwd(), OUT));
}
module.exports = { make, OUT };