Skip to content

Instantly share code, notes, and snippets.

@emotion3459
Last active January 17, 2026 00:43
Show Gist options
  • Select an option

  • Save emotion3459/cdea08e68671d8858d73b4698a24316c to your computer and use it in GitHub Desktop.

Select an option

Save emotion3459/cdea08e68671d8858d73b4698a24316c to your computer and use it in GitHub Desktop.
Toggles HDR automatically. Depends on https://github.com/dyphire/mpv-display-plugin.
local function toggle_hdr_display(target)
local hdr_status = mp.get_property_native("user-data/display-info/hdr-status")
if hdr_status and hdr_status ~= target then
mp.commandv("script-message", "toggle-hdr-display", target)
end
end
local function auto_switch(name, value)
if not value then return end
local target = (value == "pq" or value == "hlg") and "on" or "off"
toggle_hdr_display(target)
end
mp.observe_property("video-params/gamma", "native", auto_switch)
mp.register_event("end-file", function(event)
if event.reason == "quit" then
toggle_hdr_display("off")
end
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment