summaryrefslogtreecommitdiff
path: root/ar/.config/mpv/scripts/keep-window-size.lua
blob: a7ea0776deef4d0c9d06d7c00aa31ebd96c3f8b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
-- 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)