Dynamic menu bar menu
The native launcher calls your JavaScript menu provider each time the menu bar icon is
clicked. Return a fresh array so the menu reflects current app state.
const appBridge = window.HTMLtoApp;
let paused = false;
appBridge?.menuBar?.setIcon({
title: "TA",
tooltip: "Task Agent",
imagePosition: "left",
closeToMenuBarOnWindowClose: true
});
appBridge?.menuBar?.setBadge("4");
// Later, remove it and allow the user to start over.
// appBridge?.menuBar?.hideIcon?.();
appBridge?.menuBar?.setMenu(() => [
{ id: "open", title: "Open Window" },
{ type: "separator" },
{ id: "paused", title: "Paused", checked: paused, toggle: true },
{
title: "Queues",
submenu: [
{ id: "inbox", title: "Inbox" },
{ id: "done", title: "Done" }
]
},
{ type: "separator" },
{ id: "quit", title: "Quit" }
]);
appBridge?.menuBar?.onItemClick((event) => {
if (event.id === "open") appBridge.showWindow();
if (event.id === "paused") paused = event.checked;
if (event.id === "quit") appBridge.quit();
});
Window title and visibility
Update the native window title from JavaScript, hide or restore the window, and use a
menu item callback to bring a background menu bar app forward again.
window.HTMLtoApp?.setWindowTitle?.("Syncing 4 files");
window.HTMLtoApp?.hideWindow?.();
window.HTMLtoApp?.showWindow?.();