summaryrefslogtreecommitdiff
path: root/ar/.config/mpv/scripts/keep-window-size.lua
blob: 1b7487c1ced778037f56e2098b3c1aa9c6c8aa21 (plain)
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
-- keep-window-size.lua
-- Preserves window size when playlist advances to the next file.

local saved_w = nil
local restoring = false

mp.observe_property("osd-width", "number", function(_, w)
	if w and w > 0 and not restoring then
		saved_w = w
	end
end)

mp.register_event("video-reconfig", function()
	if not saved_w then
		return
	end
	local dw = mp.get_property_number("dwidth")
	if dw and dw > 0 then
		restoring = true
		mp.set_property_number("window-scale", saved_w / dw)
		mp.add_timeout(0.3, function()
			restoring = false
		end)
	end
end)