MaimoryLab/dib--plugins-dsh-desktop ↗★ 3

@maimorylab/dsh-desktop

为客户端插件提供系统菜单注册与桌面通知工具 适合需要调用系统原生通知和扩展桌面菜单功能的客户端插件开发者。

套件
@maimorylab/dsh-desktop
相容性
待驗證
Harness 依賴範圍
*
Cordis 依賴範圍
*
版本
0.2.0
授權
MIT
最近更新
2026年8月14日

安裝

此插件尚未提供可驗證的 bundle,或相容性檢查未通過。請先閱讀倉庫說明。 閱讀完整 README ↗

dsh desktop capabilities

The plugin provides ctx.desktop to client plugins. Register a stable menu item id and keep the disposer with the registering plugin:

It also registers the agent tool desktop_notify, which accepts title and body and sends a native desktop notification without another plugin.

Declare @maimorylab/dsh-desktop in dsh.client.inject and export const inject = ['desktop'] from the consuming client plugin.

const dispose = ctx.desktop.menu.register({
  id: 'my-plugin.settings',
  label: 'Settings',
  parent: 'help',
  order: 10,
  onSelect: () => openSettings(),
})

Other host capabilities use the same service:

await ctx.desktop.notify({ title: 'Done', body: 'The task finished.' })
const files = await ctx.desktop.files.choose({ multiple: true })
const offDrop = ctx.desktop.files.onDrop(paths => console.log(paths))
await ctx.desktop.openExternal('https://example.com')

Use ctx.desktop.supported(name) before optional work. The current capability names are menu, files.drop, files.choose, external.open, and notification; ctx.desktop.capabilities exposes the same list for discovery.

The service does not emulate absent capabilities; calls to missing bridges reject instead of silently doing nothing. Linux exposes menu and drag-and-drop; external.open is added when xdg-open exists, and notification when notify-send exists. File selection is intentionally omitted because GTK4 has no portable implementation here. The launcher owns its system tray lifecycle on Windows and macOS; it is not exposed to plugins.

The Windows and macOS launchers render native menus. The Linux launcher renders the same contributions in a GTK/WebKit menu bar because Linux desktop shells choose different locations for application menus.