local mp = require("mp") local utils = require("mp.utils") local function run(...) mp.msg.warn('running hooks: ' .. table.concat({ ... }, " ")) utils.subprocess_detached({ args = { "sh", "-c", table.concat({ ... }, " ") .. " >/dev/null 2>&1" }, max_size = 0, cancellable = false, }) end mp.register_event("file-loaded", function() local function cb(n, vo) if vo == true then run("run-parts", "-v", "--arg=file-loaded", "~/.config/mpv/hooks") mp.unobserve_property(cb) end end mp.observe_property("vo-configured", "bool", cb) end) mp.register_event("shutdown", function() run("run-parts", "-v", "--arg=shutdown", "~/.config/mpv/hooks") end)