summary refs log tree commit diff
path: root/.config/mpv/scripts/hooks.lua
blob: 4f350ecb1b43ae16bca745ab4f074ef5abab5d4f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
local mp = require("mp")
local utils = require("mp.utils")

local function run(...)
	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)
		-- mp.msg.warn(n, vo)
		if vo == true then
			run("makoctl", "mode", "-a", "off")
			run("svdn", "wlsunset")
			mp.unobserve_property(cb)
		end
	end
	mp.observe_property("vo-configured", "bool", cb)
end)

mp.register_event("shutdown", function()
	run("makoctl", "mode", "-r", "off")
	run("svup", "wlsunset")
end)