Skip to content

Instantly share code, notes, and snippets.

@TheAMM
Created November 13, 2018 23:33
Show Gist options
  • Save TheAMM/5e07ad787dd95d76131b61840f403a79 to your computer and use it in GitHub Desktop.
Save TheAMM/5e07ad787dd95d76131b61840f403a79 to your computer and use it in GitHub Desktop.
mpv_geometry_freezer.lua keeps your mpv window size unchanging
--[[
mpv_geometry_freezer.lua
Sets the geometry property when window size changes,
avoiding Windows' maximized windows detaching.
- AMM
]]--
local msg = require 'mp.msg'
local UPDATE_INTERVAL = 0.5
local screen_w, screen_h = mp.get_osd_size()
mp.add_periodic_timer(UPDATE_INTERVAL, function()
local new_screen_w, new_screen_h = mp.get_osd_size()
if new_screen_w ~= screen_w or new_screen_h ~= screen_h then
screen_w = new_screen_w
screen_h = new_screen_h
local geom_string = ("%dx%d"):format(screen_w, screen_h)
msg.debug("OSD resized: " .. geom_string .. ", setting geometry property")
mp.set_property_native("geometry", geom_string)
end
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment