Other mpv scripts, and programs that drive mpv over JSON IPC (--input-ipc-server), control
hookdial through two channels:
- State: they read the
user-data/hookdial/...properties, and can observe them for changes. - Commands: they send script messages.
Commands send no replies; their effects show up in the properties. An invalid command logs a
warning ([hookdial] ...) and changes nothing.
A breaking change to anything on this page bumps api_version and is listed in the release
notes. Adding a property, a field or a command is not a breaking change.
| Property | Type | Meaning |
|---|---|---|
api_version |
number | 1. Set when the script starts; absent means hookdial isn't loaded. |
open |
bool | The menu holds the keyboard. |
watching |
bool | Hot reload is on. |
shaders |
array | One entry per glsl-shaders entry, in order (below). Only present while publishing is on; see publish. |
last_error |
map | The most recent shader error: { shader, line, message, text }. line is absent when unknown; text is the line hookdial logs. Absent until the first error. |
A shaders entry (example values):
{ "name": "crt", "path": "C:/.../crt.glsl", "source": "C:/.../crt.glsl",
"status": "failed", "message": "line 12: ...",
"values": [
{ "kind": "param", "name": "mask", "type": "int", "enum": ["NONE", "APERTURE", "SLOT"],
"value": "SLOT", "default": "APERTURE", "changed": true, "desc": "Phosphor mask" },
{ "kind": "param", "name": "scanlines", "type": "float", "value": 1.0, "default": 1.0,
"min": 0.0, "max": 2.0, "changed": false },
{ "kind": "define", "name": "SHARPNESS", "type": "float", "value": 0.5, "default": 0.5,
"min": 0, "max": 1, "changed": false }
] }pathis what is inglsl-shaders. After a#definechange or a reload it is a hookdial copy.sourceis the user's file.statusis absent when the shader is fine, or"failed","unsupported"(needs vo=gpu-next) or"ambiguous"(another loaded shader has the same name).messagesays why.valueslists every//!PARAMand#define, even where the menu hides#definesliders (see thedefinesoption).type: for a//!PARAM, its declared type ("float","int","uint"or"define"). For a#define,"int"when every#defineof that name is written as a whole number (4, not4.0), else"float"; an"int"value moves in whole steps and hookdial writes it back without a decimal point.- ENUM values are names, and an ENUM has no
minormax. Other numbers are JSON numbers;min,maxanddescare absent when the shader doesn't give them.
| Command | Does |
|---|---|
open, close, toggle |
Open or close the menu. |
watch on|off|toggle |
Turn hot reload on or off. |
reload |
Reload every shader once. |
publish on|off |
Keep user-data/hookdial/shaders up to date. Off by default, so hookdial reads no shader files while nobody needs them. |
set <shader> <name> <value> |
Set a value. Out-of-range values are clamped as the sliders clamp. |
step <shader> <name> <1|-1> [fine|normal|coarse] |
Move one slider step; normal when the size is left out. |
reset <shader> [<name>] |
Reset one value, or every value of the shader. |
preset-save <shader> <preset> |
Save the shader's values as a preset. |
preset-load <shader> <preset> |
Load a preset. |
preset-delete <shader> <preset> |
Delete a preset. |
How the arguments are matched:
<shader>is the shader'sname(its file name without the extension) or its 1-based position inglsl-shaders. When two loaded shaders share a name, use the position.<name>is a//!PARAMor#definename. If a shader has both with the same name, the param is picked; writep/<name>ord/<name>to choose.<value>is a number, or for an ENUM its name or 0-based index.
A command that names a shader reads the shader files first if glsl-shaders changed since
hookdial last read them.
Presets are the same ones the menu uses, stored in ~~/script-opts/hookdial-presets.json.
Saving or deleting one fails with a warning when mpv runs without a config folder
(--no-config).
From input.conf:
Ctrl+Up script-message-to hookdial step crt scanlines 1
Ctrl+Down script-message-to hookdial step crt scanlines -1
Ctrl+w script-message-to hookdial preset-load crt warm
From a Lua script:
mp.commandv("script-message-to", "hookdial", "publish", "on")
mp.observe_property("user-data/hookdial/shaders", "native", function(_, shaders)
for _, s in ipairs(shaders or {}) do
mp.msg.info(s.name .. ": " .. #s.values .. " values")
end
end)
mp.commandv("script-message-to", "hookdial", "set", "crt", "mask", "SLOT")Over JSON IPC:
{ "command": ["script-message-to", "hookdial", "publish", "on"] }
{ "command": ["observe_property", 1, "user-data/hookdial/shaders"] }
{ "command": ["script-message-to", "hookdial", "set", "1", "scanlines", "1.4"] }