@1-week/trayicon-bun
v0.1.3
Published
Fork of trayicon by 131, rewritten natively for Bun by 1-week
Readme
trayicon-bun
Windows system tray library built natively for Bun. Forked from trayicon and redesigned to take full advantage of Bun's runtime APIs.
v2 is Bun-native. If you need Node.js compatibility, use v1.x.
What's different from the original
- Bun-native APIs: Uses
Bun.listen(),Bun.spawn(),Bun.file(),Bun.write(), andBun.CryptoHasherinstead of Node.jsnet,child_process, andfs. - TypeScript source: Written in
.tsand runs directly with Bun — no build step needed. - ESM only: Pure ESM package, no CommonJS.
- Zero dependencies: Removed the
debugnpm package entirely. bun --compilecompatible: Multi-path resolution fortrayicon.exeand support for temp-dir execution.
Requirements
- Bun >= 1.0
- Windows (relies on
trayicon.exe)
Installation
bun add @1-week/trayicon-bunUsage
import { Tray } from "@1-week/trayicon-bun";
const tray = await Tray.create({
title: "My App",
useTempDir: true,
});
tray.setMenu(
tray.item("Say Hello", () => console.log("Hello")),
tray.separator(),
tray.item("Quit", () => tray.kill())
);API
Tray.create(options?, ready?)
Creates and initializes a tray instance.
| Option | Type | Description |
|--------|------|-------------|
| title | string | Tooltip text |
| icon | Uint8Array | Icon bytes (defaults to built-in default.ico) |
| debug | boolean | Use fixed port 5678 |
| useTempDir | boolean \| "clean" | Copy trayicon.exe to temp dir ("clean" deletes on exit) |
| action | () => void | Click handler for the tray icon itself |
Instance methods
tray.setTitle(title)tray.setIcon(icon: Uint8Array)tray.setMenu(...items)tray.item(label, action?)/tray.item(label, props?)tray.separator()tray.notify(title, msg, action?)tray.kill()
Deploying with bun --compile
Place trayicon.exe next to your compiled executable:
bun build src/index.ts --compile --outfile dist/myapp.exe
cp node_modules/@1-week/trayicon-bun/rsrcs/trayicon.exe dist/Or let the library handle it automatically with useTempDir: true.
License
MIT (same as original)
