Ops HUD Kit 1.1: your Reminders and calendar on your Ulanzi deck. $19 launch price ends Dec 28 →
MDF-006 Code

Ops HUD: build a custom Ulanzi Studio plugin for the D200H macro pad

A step-by-step guide to writing your own Ulanzi Studio plugin, using my Ops HUD as the example. It turns the deck keys into live, high-contrast status tiles for the clock, weather, Mac vitals and AI teammate status.

Schematic of a 5 by 3 macro pad key grid with a wide key in the lower right. Each key is labeled with an Ops HUD key type such as NOW, AI TEAM, STATS, CLOCK and WIDE KEY.
Fig. 1 / Schematic, example layout / MDF-006

My Ulanzi D200H sits next to a Mac mini. Out of the box its keys show static icons. I wanted them to show what is going on: the time, the weather, how busy the Mac is, and whether my AI teammates are working or waiting on me. So I built a custom Ulanzi Studio plugin, Ops HUD, with help from an AI coding teammate. Each key is a small live tile, drawn several times a second.

This is a tutorial. It walks through how a Ulanzi Studio plugin is put together, using Ops HUD as the worked example, so you can build your own key types. The plugin is at version 32 and runs every day on my desk. It is not finished, and some parts are listed as not done at the end.

This works on my Mac. Your setup will differ: other paths, other apps, other data. Treat the code below as a pattern, not a drop-in install.

Data flow schematic. Data sources on the left feed data.js, then app.js, then render.js, then a send queue, then Ulanzi Studio, then the key. A dashed branch from data.js writes a live file that a browser dashboard reads.
Fig. 2 / How data gets from the Mac to a key. A dashed branch feeds the browser dashboard.

What you need

  • A Ulanzi deck that runs in Ulanzi Studio. Mine is the D200H: 13 LCD keys plus one wide key in the lower right. The dial is not used by this plugin.
  • Ulanzi Studio on a Mac. I run 3.4.16. Studio starts plugins with its own bundled Node 20.
  • Node.js and npm on your Mac, to install two packages: ws (the WebSocket client the SDK uses) and @resvg/resvg-js (turns SVG into PNG).
  • The Ulanzi Node SDK (plugin-common-node) and the browser SDK (libs/) from Ulanzi’s plugin SDK.
  • A text editor and Terminal.
  • Some data you want to see. Mine comes from small JS files on disk, local HTTP health checks, macOS command-line tools and a public weather API.

Step 1: Lay out the plugin folder

A plugin is one folder whose name ends in .ulanziPlugin. Ulanzi Studio reads manifest.json, then starts the file named in CodePath with Node. That file is the main service. It stays connected to Studio the whole time.

Tree diagram of a plugin folder: manifest.json, en.json, package.json, a plugin folder with app.js, render.js, data.js, icons.js and the Node SDK, a property-inspector folder, libs and assets.
Fig. 3 / Plugin folder anatomy. render.js is where the keys get drawn.

My split is simple:

  • app.js handles Studio events, timers and the send queue.
  • data.js polls each data source and writes into one shared state object.
  • render.js turns state into one SVG per key, then into a PNG.
  • icons.js holds line-icon paths (Lucide, ISC license).
  • assets/fonts/ holds the TTF fonts the renderer uses. assets/icons/ holds the PNGs shown in the Studio action list.

package.json needs only two dependencies:

{
  "name": "myhud-ulanzi",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "dependencies": {
    "@resvg/resvg-js": "^2.6.2",
    "ws": "^8.18.0"
  }
}

Run npm install inside the plugin folder before you copy it into Studio.

Step 2: Write the manifest and your actions

The manifest names the plugin, points at the main service and lists every action. An action is a key type you can drag onto the deck in Studio.

{
  "Name": "My HUD",
  "Version": "1.0.0",
  "Icon": "assets/icons/plugin.png",
  "Category": "My HUD",
  "CodePath": "plugin/app.js",
  "Type": "JavaScript",
  "UUID": "com.example.ulanzistudio.myhud",
  "Actions": [
    {
      "Name": "Mac Live Stats",
      "UUID": "com.example.ulanzistudio.myhud.stats",
      "Icon": "assets/icons/stats.png",
      "Tooltip": "CPU % and RAM % with thick bars.",
      "States": [{ "Name": "Live", "Image": "assets/icons/stats.png" }],
      "SupportedInMultiActions": false,
      "DisableAutomaticStates": true,
      "Controllers": ["Keypad"]
    }
  ],
  "OS": [{ "Platform": "mac", "MinimumVersion": "12" }],
  "Software": { "MinVersion": "3.0.0" }
}

Two rules from the SDK readme matter here. The plugin UUID has exactly four dot-separated parts. Each action UUID adds one more part on the end. My code uses that last part as the key type, so ...myhud.stats becomes stats.

Ops HUD has 17 actions, including COS State, Waiting On You, Mac Vitals, Memory, HUD Clock, Digital Clock, Live Weather, Now Doing, AI teammate status and a styled launcher. Once installed, you drag actions onto keys in Studio. Keys are addressed as column_row.

Schematic of the deck key grid. Five columns by three rows with ids from 0_0 to 4_1, and a wide key 3_2 that spans two columns. Dimension lines show 196 px and 458 px.
Fig. 4 / Key grid. Ids are column_row. The wide key is 3_2. Example layout, not the exact live profile.

Step 3: Connect app.js to Studio

app.js connects to Studio, keeps a map of every key on the deck, and reacts to events. The context string is unique per key, so the same action can sit on several keys with different settings.

import UlanziApi from './plugin-common-node/index.js';

const PLUGIN = 'com.example.ulanzistudio.myhud';
const $UD = new UlanziApi();
const keys = new Map(); // context -> { action, key, param, active, lastSvg }
const kind = (uuid) => String(uuid || '').split('.').pop();

$UD.connect(PLUGIN);
$UD.on('close', () => process.exit(0)); // Studio went away
$UD.onAdd((m) => {
  keys.set(m.context, { context: m.context, action: m.uuid, key: m.key,
    param: m.param || {}, active: true, lastSvg: '' });
  paint(m.context, true);
});
$UD.onParamFromApp((m) => {
  const k = keys.get(m.context);
  if (k) { k.param = { ...k.param, ...(m.param || {}) }; paint(m.context, true); }
});
$UD.onSetActive((m) => {
  const k = keys.get(m.context);
  if (k) { k.active = m.active !== false; if (k.active) paint(m.context, true); }
});
$UD.onClear((m) => { for (const it of m.param || []) keys.delete(it.context); });

Studio has no separate hold event that I use, so a long press is a timer. Key down starts a 700 ms timer. Key up clears it. If the timer fired, the next onRun is swallowed so a hold does not also count as a tap.

$UD.onKeyDown((m) => {
  const k = keys.get(m.context); if (!k) return;
  k.held = false;
  clearTimeout(k.holdTimer);
  k.holdTimer = setTimeout(() => { k.held = true; longPress(k); }, 700);
});
$UD.onKeyUp((m) => { const k = keys.get(m.context); if (k) clearTimeout(k.holdTimer); });
$UD.onRun((m) => {
  const k = keys.get(m.context); if (!k) return;
  clearTimeout(k.holdTimer);
  if (k.held) { k.held = false; return; }
  press(k);
});

Step 4: Draw a key image

Each key is an SVG string. Normal keys are 196 x 196 px. The wide key is 458 x 196 px. render.js builds the SVG, then resvg turns it into a PNG data URL, and app.js sends that to Studio with $UD.setBaseDataIcon(context, pngDataUrl, '').

Drawing as SVG text has a nice side effect. If the string has not changed, the key does not need a redraw.

The keys are about 14 mm across, so I set hard readability rules at the top of render.js: one big hero value, one bold label, one short status line, no text under 22 px, strokes at least 3 px, near-white text on near-black. A fit() helper shrinks text to fit, then trims it with an ellipsis, but never goes below 22 px. A shared frame() draws the background, outline and glow so every key looks related.

import { Resvg } from '@resvg/resvg-js';

const FONT = 'JetBrains Mono';
const MIN_FS = 22;

// Shrink to fit a monospace width (about 0.6 em per character), never below MIN_FS.
function fitSize(text, maxW, maxSize, minSize = MIN_FS) {
  const n = Math.max(1, String(text).length);
  return Math.max(minSize, Math.min(maxSize, Math.floor(maxW / (n * 0.6))));
}

export function svgStats({ cpu = 0, mem = 0 } = {}) {
  const cc = cpu > 85 ? C.red : cpu > 65 ? C.amber : C.cyan;
  const inner = `
  ${LABEL(98, 40, 'CPU')}
  ${HERO(98, 106, `${Math.round(cpu)}%`, cc, { max: 72 })}
  ${bar(30, 118, 136, cpu, cc)}
  ${T(98, 164, `RAM ${Math.round(mem)}%`, { w: 160, max: 30, fill: C.green, weight: 800 })}
  ${bar(30, 172, 136, mem, C.green, 12)}`;
  return frame(196, 196, cc, inner);
}

export function toDataUrl(svg, width) {
  const png = new Resvg(svg, {
    fitTo: { mode: 'width', value: width },
    font: { fontFiles: FONT_FILES, loadSystemFonts: false, defaultFontFamily: FONT },
  }).render().asPng();
  return 'data:image/png;base64,' + Buffer.from(png).toString('base64');
}

loadSystemFonts: false means the fonts in assets/fonts/ are the only fonts. The keys look the same on any Mac.

These are actual key renders from render.js, with demo data:

Rendered key: CPU 34 percent in large cyan text with a bar, and RAM 62 percent in green with a bar.
Fig. 5 / Mac Live Stats key. Actual render, demo data.
Rendered key: a bell icon, a large amber number 3, the label WAITING and the status line Review draft.
Fig. 6 / Waiting count key. Actual render, demo data.
Rendered key: a seven-segment clock reading 2:42 with THU 15 above and PM below, in cyan and amber.
Fig. 7 / Digital Clock key with crisp seven-segment digits. Actual render, demo data.
Rendered wide key: download and upload rates with unit pills, a ping readout, and wave lines for traffic history.
Fig. 8 / Network flow on the wide key, 458 x 196 px. Actual render, demo data.

Step 5: Feed it live data

All data lands in one state object in data.js. Each source has its own poll loop at its own speed. Keys read from state. They never wait on a slow source.

Many of my sources are small JS files on disk in the form window.X = {...}. A browser page can load these with a plain script tag, and the plugin can read them too. The plugin runs each file in a sandbox with vm.runInNewContext and only re-reads it when the file’s modified time changes.

import fs from 'node:fs';
import vm from 'node:vm';

let mtime = 0;
export async function pollStatus(p = `${HOME}/.../status.js`) {
  try {
    const st = await fs.promises.stat(p);
    if (st.mtimeMs !== mtime) {
      mtime = st.mtimeMs;
      const sandbox = { window: {} };
      vm.runInNewContext(await fs.promises.readFile(p, 'utf8'), sandbox, { timeout: 200 });
      const s = sandbox.window.MY_STATUS || {};
      state.status.state = String(s.state || 'idle').toLowerCase();
      state.status.updatedAt = s.updated_at ? Date.parse(s.updated_at) : st.mtimeMs;
    }
    // Older than 3 minutes counts as idle.
    const stale = Date.now() - state.status.updatedAt > 3 * 60 * 1000;
    state.status.effective = stale ? 'idle' : state.status.state;
  } catch {
    state.status.effective = 'offline';
  }
}

Each AI teammate writes its own small heartbeat file in the same style, so several writers never fight over one file:

(window.OPS_SELF = window.OPS_SELF || {})["teammate-a"] = {
  name: "Teammate A", state: "working", task: "Demo task",
  updated: "2026-01-15T14:42:00Z", waiting: []
};

Other sources:

  • Mac vitals from vm_stat, sysctl, statfs and os.cpus().
  • Front app and Dock badges from lsappinfo.
  • Local AI health from an HTTP ping to the Ollama and Open WebUI ports on 127.0.0.1.
  • Weather from Open-Meteo, plus National Weather Service alerts for a red or amber border.

Then the loops in app.js. The clock ticks once a second, lined up to the start of each second. Animations run at 250 ms. Status runs every 2 to 5 seconds. Slow AppleScript runs every 60 seconds. Weather runs every 5 minutes.

function clockTick() {
  paintAll((t) => t === 'clock');
  setTimeout(clockTick, 1000 - (Date.now() % 1000) + 15);
}
clockTick();
setInterval(async () => { await D.pollStatus(); paintAll((t) => t === 'cos'); }, 2000);
setInterval(() => paintAll((t) => t === 'wxlive' || t === 'segclock'), 250);

paint() compares the new SVG with the last one and skips the key if nothing changed. That keeps a 250 ms loop cheap.

Rendered key: a glowing cyan orb with orbit dots, the word WORKING, the status line Build plugin, and an amber dot in the corner.
Fig. 9 / Status orb key reading a status file. Actual render, demo data.
Rendered key: 1 WORKING at the top, then four generic teammates AI 1 to AI 4 with cyan, gray and amber dots.
Fig. 10 / AI teammate roster built from heartbeat files. Actual render, demo data.

The browser dashboard

The same files feed a browser page I call the COS Dashboard. It reloads the status file every 2 seconds and shows IDLE when that file is more than 3 minutes old, the same rule the keys use. Every 2 seconds the plugin also writes a live.js file with the front app, CPU, memory, disk, network and top processes, and the dashboard shows that in a live Mac panel. Because a page opened from file:// cannot just re-fetch a script, the dashboard removes and re-adds its script tags to reload them.

One catch: the live panel only updates while Ulanzi Studio is running, because the plugin is what writes the file.

Step 6: Add a settings panel (property inspector)

The property inspector is the small settings form Studio shows when you select a key. Mine is one page, property-inspector/inspector.html, that loads the browser SDK from libs/js/ and then inspector.js. The page reads the action UUID from its URL and builds only the fields that action needs.

const F = {
  label: { t: 'text', l: 'Label' },
  app:   { t: 'text', l: 'App' },
  url:   { t: 'text', l: 'URL' },
  h24:   { t: 'check', l: '24-hour' },
};
const LAYOUT = { launch: ['label', 'app', 'url'], clock: ['h24'], stats: [] };

const kind = (Utils.getQueryParams('uuid') || '').split('.').pop();
let SETTINGS = {};

$UD.connect();
$UD.onConnected(() => {
  build(); // add a form row for each field in LAYOUT[kind]
  Utils.setFormValue(SETTINGS, form);
  form.addEventListener('input', Utils.debounce(() => {
    SETTINGS = { ...SETTINGS, ...Utils.getFormValue(form) };
    $UD.sendParamFromPlugin(SETTINGS);
  }));
});
const load = (j) => { if (j && j.param) { SETTINGS = j.param; Utils.setFormValue(SETTINGS, form); } };
$UD.onAdd(load);
$UD.onParamFromApp(load);

The panel sends settings with sendParamFromPlugin. The main service gets them in onParamFromApp (Step 3), merges them into that key’s param and repaints. Keep the panel light. Studio destroys it every time you pick another key.

How Studio finds the inspector page for each action: TBD. My manifest has no inspector path field, so check Ulanzi’s manifest.md for your SDK version.

Step 7: Install and reload in Ulanzi Studio

Plugins live here:

~/Library/Application Support/Ulanzi/UlanziDeck/Plugins/<your-id>.ulanziPlugin/

My reload routine, as a script:

PL="$HOME/Library/Application Support/Ulanzi/UlanziDeck/Plugins/com.example.myhud.ulanziPlugin"
osascript -e 'quit app "Ulanzi Studio"'; sleep 3
pkill -x UlanziDeck; sleep 2
cp -R ./com.example.myhud.ulanziPlugin/plugin/. "$PL/plugin/"
"/Applications/Ulanzi Studio.app/Contents/MacOS/NodeJS/node" --check "$PL/plugin/app.js" && echo syntax-ok
open -a "Ulanzi Studio"

The --check step uses Studio’s own bundled Node, so a syntax error shows up in Terminal instead of as a blank key. I also back up the old plugin files before each copy.

Log to a file. Mine writes timestamped lines to ~/Library/Logs/<YourPlugin>.log for connect, add, render errors and send errors. When a key goes blank, that log is the first place to look.

Step 8: Make your own key type

Adding a key type touches four places:

  1. Add an action to manifest.json with a new UUID ending, for example ...myhud.uptime.
  2. Add an svgUptime() function to render.js that returns an SVG string built with the shared frame(), HERO() and LABEL() helpers.
  3. Add a case 'uptime': to svgFor() in app.js that calls it with data from state.
  4. If it needs new data, add a poll function in data.js and a timer in app.js. If it needs a tap action, add a case to press().
// render.js
export function svgUptime({ hours = 0 } = {}) {
  const inner = `
  ${HERO(98, 110, `${Math.floor(hours)}h`, C.cyan)}
  ${LABEL(98, 160, 'UPTIME')}`;
  return frame(196, 196, C.cyan, inner);
}

// app.js, inside svgFor(k)
case 'uptime': return R.svgUptime({ hours: D.state.vitals.uptimeH });

Reload Studio (Step 7), drag the new action onto a key, and it draws on the next paint.

Rendered key: an app window icon, 8m time on app, the word EDITOR, CPU 12 percent and RAM 1.2G.
Fig. 11 / Now Doing key: front app, time on it, and its CPU and RAM. Actual render, demo data.

Gotchas

  • USB bursts cause stutter. Sending many images at once made the deck lag. The fix is a send queue: keep only the newest frame per key, send at most 3 images every 40 ms, send the clock first, and cache PNGs so an identical SVG is never rasterized twice.
  • Studio draws over the wide key. Studio drew its own clock on top of the plugin until the wide key was set to background-only mode with the plugin running it.
  • Art can look off-center on the glass. I added an offset.json file with { "x": 0, "y": 0, "s": 1 } that the plugin re-reads every 3 seconds. It shifts and scales every key image to line up with the display.
  • Keep text at 22 px or more. My first design was hard to read. The redraw went to one big number or word, a bold label, brighter text and art inset from the edges.
  • Blur makes seven-segment digits muddy. Draw crisp segments with no blur filter.
  • AppleScript is slow. Mail counts through AppleScript run every 60 seconds and only while Mail is open. Put slow sources on their own slow loop.
  • Half-written files. Write data files to a temp file and rename it into place. When a read fails, keep the last good data.
  • Stale data looks live. Treat a status older than 3 minutes as idle, and a “working” heartbeat older than 20 minutes as idle.
  • “User canceled (-128)” on a scripted quit is harmless. It can show up when the reload script quits Studio.
  • Studio caches the profile. Only edit the profile files while Studio is closed.
  • Exit when Studio closes the socket. The plugin calls process.exit(0) on close so Studio can start a clean copy next time.

What’s next

What is done: 17 action types, the Home profile, the wide network-flow key, the Live Weather key with alert borders, and the browser dashboard that shares the plugin’s data. It runs every day at v32.

A version you can install: the Ops HUD Kit packages this for the Ulanzi D200 and D200H on macOS. No account, no subscription, no AI credits. Your data stays on your Mac.

What is not done or was dropped:

  • The dial is not used yet.
  • A sleep feature that blacked out the deck and set brightness to 0 was removed. The deck was still too bright to be worth it.
  • Time spent and cost: TBD.

If you want to see where this goes next, follow the build log or join the email list.

TitleOps HUD: build a custom Ulanzi Studio plugin for the D200H macro pad
Dwg no.MDF-006
DateNov 28, 2026
RevA
MachineUlanzi D200H deck + Mac mini M1
Scale1:1
StationTBD
Sheet1 / 1
MDF-006 / Reader notes

Comments

    Leave a comment

    Every comment is read by Austin before it shows up. No account needed. Links show as plain text.

    2000 characters left