8000
Skip to content

Instantly share code, notes, and snippets.

@krisu5
Last active March 1, 2026 11:03
Show Gist options
  • Select an option

  • Save krisu5/a73483de851dfdb240e0c244ef1edb B731 97 to your computer and use it in GitHub Desktop.

Select an option

Save krisu5/a73483de851dfdb240e0c244ef1edb97 to your computer and use it in GitHub Desktop.
-- Toggle redshift when viewing videos with mpv
-- When pausing redshift is reenabled (and disabled again when continuing)
-- This script assumes that redshift is running
-- Original script by CreamyCookie, retrieved from Wayback Machine: https://web.archive.org/web/20221014123046/https://gist.github.com/CreamyCookie/d036b66af4e17ea527d08e303eb96145
rs_enabled = true
function rs_toggle()
os.execute("pkill -x -USR1 redshift")
end
function rs_disable()
if rs_enabled then
rs_toggle()
rs_enabled = false
mp.msg.log("info", "Disabling redshift")
end
end
function rs_enable()
if not rs_enabled then
rs_toggle()
rs_enabled = true
mp.msg.log("info", "Reenabling redshift")
end
end
function rs_handler()
if mp.get_property("video") ~= "no" then
rs_disable()
else
rs_enable()
end
end
function on_pause_change(name, value)
if value then --pause started
rs_enable()
else
rs_disable()
end
end
mp.register_event("file-loaded", rs_handler)
mp.register_event("shutdown", rs_enable)
mp.observe_property("pause", "bool", on_pause_change)

Comments are disabled for this gist.

0