Messages
Every message is one JSON object on one line with a type. Ignore types you don't know: future versions of Nook will add more.
Your program to Nook (stdout)
| type | Fields | Effect |
|---|---|---|
tile | view | Replaces the tile. |
page | view actions? | Replaces the page. Once you send a page, clicking the tile opens it. actions are round header buttons: [{id, icon, tooltip}]. |
badge | badge | Shows something in the collapsed pill. null clears it. See below. |
active | active | Lights the tile with the accent color. |
open_page / close_page | Opens or closes your page, if the panel is open. | |
show | Opens the notch, pinned, on your page. Use it for alerts. | |
copy | text | Puts text on the clipboard. |
open | target | Opens a URL, file or folder with its default app. |
log | level message | Writes to Nook's log: debug, info, warn or error. |
Badges
| Badge | Shows |
|---|---|
{"kind": "ring", "progress": 0.4, "label": "12:00"} | A progress ring and a short label, in place of the pill's clock. |
{"kind": "glyph", "icon": "bell"} | A small icon on the right of the pill. |
{"kind": "pulse"} | A pulsing dot: something arrived. |
Nook to your program (stdin, live mode)
| type | Fields | When |
|---|---|---|
hello | protocol nook_version plugin_id data_dir theme{dark,accent} | First, right after your program starts. |
event | id kind value? | A control was used. kind is click change submit commit. |
tile_click | The tile was clicked somewhere other than one of your controls. | |
page_open / page_close | Your page appeared or went away. Do expensive work only while it's open. | |
layout | target size width height | The space for your tile or page in points. Sent again when it changes. |
theme | dark accent | The user changed the theme or accent color. |
hotkey | Your manifest's hotkey was pressed. | |
files | paths | Files were dropped on your open page (needs accepts_files). |
shutdown | Nook is quitting or reloading. Save your state now; the program is stopped 0.4 s later. |
A full exchange
json
← {"type":"hello","protocol":1,"nook_version":"0.1.0","plugin_id":"counter","data_dir":"C:\\Users\\you\\AppData\\Roaming\\Nook\\plugin-data\\counter","theme":{"dark":true,"accent":"#7C5CFF"}}
→ {"type":"tile","view":{"type":"text","text":"0","size":"title"}}
← {"type":"layout","target":"tile","size":"small","width":44,"height":44}
← {"type":"event","id":"inc","kind":"click"}
→ {"type":"tile","view":{"type":"text","text":"1","size":"title"}}
→ {"type":"badge","badge":{"kind":"ring","progress":0.1,"label":"1"}}← is stdin (from Nook), → is stdout (from your program).