app.plugin - Plugin Info
Query metadata about the current plugin.
Methods
app.plugin.id()
Get the unique identifier of the current plugin.
Returns: string
local id = app.plugin.id()
-- "com.example.myplugin"
app.plugin.name()
Get the display name of the current plugin.
Returns: string
local name = app.plugin.name()
-- "My Plugin"
app.plugin.version()
Get the version string of the current plugin.
Returns: string
local ver = app.plugin.version()
-- "1.2.3"
app.plugin.author()
Get the author of the current plugin.
Returns: string
local author = app.plugin.author()
-- "ByteAge"
app.plugin.description()
Get the description text of the current plugin.
Returns: string
local desc = app.plugin.description()
-- "A handy file processing plugin"
app.plugin.installPath()
Get the installation directory path of the current plugin.
Returns: string
local dir = app.plugin.installPath()
-- "/Users/alice/Library/Application Support/iRightMenu/Plugins/myplugin.rmx"
-- Read a resource file bundled with the plugin
local icon = app.path.join(dir, "icon.png")
local content = app.file.read(app.path.join(dir, "data.json"))
app.plugin.metadata()
Get the full metadata table of the current plugin.
Returns: table - all fields from plugin.json
local meta = app.plugin.metadata()
-- {
-- id = "com.example.myplugin",
-- name = "My Plugin",
-- version = "1.2.3",
-- author = "ByteAge",
-- description = "...",
-- minAppVersion = "2.0.0",
-- permissions = {"file", "shell"},
-- ...
-- }
app.log.info("Plugin version: " .. meta.version)
Description
- L0 security module — available to all plugins without additional permissions
- Replaces the implicit
self:getName()and related methods on the Plugin base class - Replaces the deprecated
_PLUGIN_DIRand_PLUGIN_METADATAglobal variables app.plugin.installPath()returns the directory of the unpacked.rmxbundle; use it withapp.path.jointo access bundled resources
Examples
Reading Bundled Resources
function MyPlugin:onMenuItems(context)
local dir = app.plugin.installPath()
-- Load the plugin's built-in HTML template
local templatePath = app.path.join(dir, "templates", "default.html")
local template = app.file.read(templatePath)
if not template then
app.log.error("Template not found: " .. templatePath)
return
end
-- Display in a WebView window
app.webview.open({html = template, title = app.plugin.name()})
end
Logging Version Info
function MyPlugin:onMenuItems(context)
local meta = app.plugin.metadata()
app.log.info(string.format(
"Plugin %s v%s (by %s) triggered",
meta.name, meta.version, meta.author
))
end