跳转到内容
套件 / 通知 / 首屏
NotificationsHoody 通知

通过 HTTP 发送桌面通知。

通过单次 HTTP POST 向任意容器显示器发送 Linux 桌面通知。通知服务器在容器的 X11 显示器上调用 notify-send——触发、获取历史记录或实时流式传输。

notify · hoody-n

# 向显示器 0 发送通知

curl -X POST ".../notify"

-d '["display":"0","summary":"Build Complete","urgency":"normal"]'

# 响应

["message":"Notification sent successfully","success":true]

套件 / 通知 / 生命周期
工作原理

三个步骤,每步一次 HTTP 调用。

每条通知遵循相同的生命周期:触发、获取历史或实时流式传输、完成后关闭。

01

触发

POST /notify 向目标 X11 显示器发送 notify-send 调用。提供 display、summary,以及可选的 urgency、body、expire_time 或 icon。

通知 — 触发

# 发送通知

POST /notify

 

# 请求体

["display":"0","summary":"Build Complete",

"urgency":"normal","body":"All tests passed"]

02

获取或流式传输

GET /[display] 获取通知历史,支持可选的 limit、since、username 和 session 筛选。通过 WebSocket 连接 /stream?displays=0 可获取实时推送更新。

通知 — 获取

# 轮询历史记录

curl ".../0?limit=50"

 

# 或打开 WebSocket

new WebSocket("wss://.../stream?displays=0")

03

关闭

POST /dismiss 将通知 ID 标记为已关闭——它们将从后续 GET 响应中过滤。DELETE /dismiss 清除已关闭状态,使其重新可见。

通知 — 关闭

# 按 ID 关闭

POST /dismiss

["displayId":"0","notificationIds":[10,11,12]]

 

# 清除关闭状态

DELETE /dismiss?displayId=0

套件 / 通知 / 紧急程度
紧急程度级别

low、normal、critical。

三个紧急程度级别直接映射到 notify-send 行为。选择合适的级别,通知守护进程负责其余处理。

low

快速消失。将 expire_time 设为 3000,适用于后台任务、遥测或不应打断专注的信息性提示。

"urgency": "low",

"expire_time": 3000

normal

标准级别。省略 urgency 时的默认值。通知守护进程在配置的超时后显示并自动关闭。

"urgency": "normal"

// default — omit to use this

critical

持久显示——需要手动关闭。将 expire_time 设为 0,适用于系统故障、构建错误或任何需要立即处理的情况。

"urgency": "critical",

"expire_time": 0

套件 / 通知 / 频道
频道

获取历史或实时流式传输。

两个读取频道满足不同需求:REST 用于审计日志和一次性查询,WebSocket 用于仪表盘和实时监控。

GETGET /[display]Fetch
WSWS /streamStream

获取某个显示器的通知历史,支持按 limit、since 时间戳、username 或 session ID 筛选。适用于审计日志、一次性查询和批量处理。

fetch history

# get last 50 for display 0

curl ".../0?limit=50"

# time-filtered

curl ".../0?since=1749025000000"

包含 id、summary、urgency、timestamp 和 icon_url 的通知对象 JSON 数组。

使用 displays=0,:1,2 或 displays=all 订阅一个或多个显示器。消息到达时实时推送。适用于仪表盘和实时监控。

stream live

# open a WebSocket

const ws = new WebSocket(

"wss://.../stream?displays=0"

)

# on message

ws.onmessage = (e) => {

const msg = JSON.parse(e.data)

// msg.type === 'notification'

}

每条新通知到达时推送 [ type: "notification", data: [ id, summary, urgency, timestamp ] ]。

套件 / 通知 / 使用场景
使用场景

从构建流水线到 ML 任务。

任何长时间运行的进程需要发出完成或失败信号时,一次 HTTP POST 即可搞定。

CI/CD 告警

长时间构建完成后,HTTP POST 在容器显示器上触发通知——在任意活跃的显示器会话中可见。

系统监控

服务器告警路由到容器 X11 显示器上的桌面通知,在任意活跃的显示器会话中可见。

长时间运行的任务

数据导出、视频渲染、ML 模型训练、备份完成——完成时通知,无需轮询。

自动化工作流

Cron 作业、定时任务和自动化脚本在完成或失败时通知容器显示器。

主页 / 套件 / 通知 / API
API 参考

8 个端点。一个通知服务器。

创建主题和订阅者、触发推送通知、流式传输事件并检索交付历史——全部通过简单 HTTP。

Trigger

{count, plural, =1 {# 个端点} other {# 个端点}'}

POST .../api/v1/notifications/notify → {"success":true}

POST
/api/v1/notifications/notifySend a native desktop notification to a target display via notify-send

Fetch & Stream

{count, plural, =1 {# 个端点} other {# 个端点}'}

GET .../api/v1/notifications/{display}?limit=50&since=...

GET
/api/v1/notifications/{display}Retrieve notification history for one or more displays
WS
/api/v1/notifications/stream?displays=0,:1Real-time WebSocket stream — push updates as notifications arrive
POST
/api/v1/notifications/dismissMark notification IDs as dismissed; filtered from subsequent GET responses
DELETE
/api/v1/notifications/dismissClear dismissed state — restore notifications to visible

Icons

{count, plural, =1 {# 个端点} other {# 个端点}'}

GET .../api/v1/notifications/icons/{iconId} → image/png

GET
/api/v1/notifications/icons/{iconId}Fetch notification icon (JPEG, PNG, or SVG) by unique icon ID

Health & Metrics

{count, plural, =1 {# 个端点} other {# 个端点}'}

GET .../api/v1/notifications/health → {"status":"UP"}

GET
/api/v1/notifications/healthEnhanced health check — filesystem, WebSocket, and memory status
GET
/api/v1/notifications/metricsPrometheus-compatible metrics for notifications sent, failed, and CPU/memory
套件 / 通知 / CTA

通知只需一次 HTTP POST。

任何能发出 HTTP 请求的脚本、服务或自动化程序都可以向你的容器显示器发送桌面通知。

阅读文档