docs: update plugin development guide for main defaults, register API, hot-reload
- entry_point → entry (canonical); note alias in manifest section
- Lua quick start and provider functions rewritten for owlry.provider.register() API
- owlry table is pre-registered globally; remove require("owlry") references
- Items documented as plain Lua tables, not method-chained owlry.item() objects
- owlry_version bumped to >=1.0.0 in manifest example
- Rune manifest entry_point → entry
- Add Hot Reload section documenting file-watcher behavior and caveats
This commit is contained in:
@@ -115,7 +115,7 @@ id = "my-lua-plugin"
|
|||||||
name = "My Lua Plugin"
|
name = "My Lua Plugin"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
description = "A custom Lua plugin"
|
description = "A custom Lua plugin"
|
||||||
entry_point = "init.lua"
|
entry = "main.lua"
|
||||||
|
|
||||||
[[providers]]
|
[[providers]]
|
||||||
id = "myluaprovider"
|
id = "myluaprovider"
|
||||||
@@ -126,23 +126,27 @@ type = "static"
|
|||||||
type_id = "mylua"
|
type_id = "mylua"
|
||||||
```
|
```
|
||||||
|
|
||||||
Create `~/.config/owlry/plugins/my-lua-plugin/init.lua`:
|
Create `~/.config/owlry/plugins/my-lua-plugin/main.lua`:
|
||||||
```lua
|
```lua
|
||||||
local owlry = require("owlry")
|
-- owlry table is pre-registered globally (no require needed)
|
||||||
|
owlry.provider.register({
|
||||||
-- Called once at startup for static providers
|
name = "myluaprovider",
|
||||||
function refresh()
|
display_name = "My Lua Provider",
|
||||||
return {
|
type_id = "mylua",
|
||||||
owlry.item("item-1", "Hello from Lua", "echo 'Hello Lua!'")
|
default_icon = "application-x-executable",
|
||||||
:description("A Lua greeting")
|
prefix = ":mylua",
|
||||||
:icon("face-smile"),
|
refresh = function()
|
||||||
}
|
return {
|
||||||
end
|
{
|
||||||
|
id = "item-1",
|
||||||
-- Called per-keystroke for dynamic providers
|
name = "Hello from Lua",
|
||||||
function query(q)
|
command = "echo 'Hello Lua!'",
|
||||||
return {}
|
description = "A Lua greeting",
|
||||||
end
|
icon = "face-smile",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -330,8 +334,8 @@ id = "my-plugin"
|
|||||||
name = "My Plugin"
|
name = "My Plugin"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
description = "Plugin description"
|
description = "Plugin description"
|
||||||
entry_point = "init.lua"
|
entry = "main.lua" # Canonical field; entry_point is accepted as an alias
|
||||||
owlry_version = ">=0.4.0" # Optional version constraint
|
owlry_version = ">=1.0.0" # Optional version constraint
|
||||||
|
|
||||||
[permissions]
|
[permissions]
|
||||||
fs = ["read"] # File system access
|
fs = ["read"] # File system access
|
||||||
@@ -350,14 +354,10 @@ type_id = "shortid"
|
|||||||
### Lua API
|
### Lua API
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local owlry = require("owlry")
|
-- owlry table is pre-registered globally (no require needed)
|
||||||
|
|
||||||
-- Create items
|
-- Items are plain Lua tables returned from refresh/query callbacks:
|
||||||
local item = owlry.item(id, name, command)
|
-- { id = "...", name = "...", command = "...", description = "...", icon = "...", terminal = false, tags = {"...", "..."} }
|
||||||
:description("Description")
|
|
||||||
:icon("icon-name")
|
|
||||||
:terminal(false)
|
|
||||||
:keywords({"tag1", "tag2"})
|
|
||||||
|
|
||||||
-- Notifications
|
-- Notifications
|
||||||
owlry.notify("Title", "Body")
|
owlry.notify("Title", "Body")
|
||||||
@@ -388,24 +388,31 @@ local value = owlry.cache.get("key")
|
|||||||
### Provider Functions
|
### Provider Functions
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- Static provider: called once at startup
|
-- Static provider: called once at startup and on reload
|
||||||
function refresh()
|
owlry.provider.register({
|
||||||
return {
|
name = "my-provider",
|
||||||
owlry.item("id1", "Item 1", "command1"),
|
display_name = "My Provider",
|
||||||
owlry.item("id2", "Item 2", "command2"),
|
prefix = ":my",
|
||||||
}
|
refresh = function()
|
||||||
end
|
return {
|
||||||
|
{ id = "id1", name = "Item 1", command = "command1" },
|
||||||
|
{ id = "id2", name = "Item 2", command = "command2" },
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
-- Dynamic provider: called on each keystroke
|
-- Dynamic provider: called on each keystroke
|
||||||
function query(q)
|
owlry.provider.register({
|
||||||
if q == "" then
|
name = "my-search",
|
||||||
return {}
|
display_name = "My Search",
|
||||||
end
|
prefix = "?my",
|
||||||
|
query = function(q)
|
||||||
return {
|
if q == "" then return {} end
|
||||||
owlry.item("result", "Result for: " .. q, "echo " .. q),
|
return {
|
||||||
}
|
{ id = "result", name = "Result for: " .. q, command = "echo " .. q },
|
||||||
end
|
}
|
||||||
|
end,
|
||||||
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -421,7 +428,7 @@ Rune plugins use a Rust-like syntax with memory safety.
|
|||||||
id = "my-rune-plugin"
|
id = "my-rune-plugin"
|
||||||
name = "My Rune Plugin"
|
name = "My Rune Plugin"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
entry_point = "main.rn"
|
entry = "main.rn"
|
||||||
|
|
||||||
[[providers]]
|
[[providers]]
|
||||||
id = "runeprovider"
|
id = "runeprovider"
|
||||||
@@ -524,6 +531,29 @@ RUST_LOG=debug owlry
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Hot Reload
|
||||||
|
|
||||||
|
User plugins in `~/.config/owlry/plugins/` are automatically reloaded when files change.
|
||||||
|
The daemon watches the plugins directory and reloads all script runtimes when any file
|
||||||
|
is created, modified, or deleted. No daemon restart is needed.
|
||||||
|
|
||||||
|
**What triggers a reload:**
|
||||||
|
- Creating a new plugin directory with `plugin.toml`
|
||||||
|
- Editing a plugin's script files (`main.lua`, `main.rn`, etc.)
|
||||||
|
- Editing a plugin's `plugin.toml`
|
||||||
|
- Deleting a plugin directory
|
||||||
|
|
||||||
|
**What does NOT trigger a reload:**
|
||||||
|
- Changes to native plugins (`.so` files) — these require a daemon restart
|
||||||
|
- Changes to runtime libraries in `/usr/lib/owlry/runtimes/` — daemon restart needed
|
||||||
|
|
||||||
|
**Reload behavior:**
|
||||||
|
- All script runtimes (Lua, Rune) are fully reloaded
|
||||||
|
- Existing search results may briefly show stale data during reload
|
||||||
|
- Errors in plugins are logged but don't affect other plugins
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Publishing to AUR
|
## Publishing to AUR
|
||||||
|
|
||||||
### PKGBUILD Template
|
### PKGBUILD Template
|
||||||
|
|||||||
Reference in New Issue
Block a user