@Chainik: Thanks, looking forward to it :-).
@edgedashin: Yeah, but doing that seems like a pretty dirty hack to me (mpv triggering screen refresh rate change via mpv-kscreen-doctor works great, but then it would need to kill and restart SVPManager which is in turn hooking into mpv...).
I've attached the code of a lua script for mpv doing just that (can be used in addition to mpv-kscreen-doctor), but it plays some dirty tricks and I would not recommend anybody to solve it this way.
Also, it kill-restarts SVPManager at least once whenever mpv is freshly opened and starts playing in the current state, as of course it does not know what the previous state is (for example there could have been an external refresh rate change or a leftover from a refresh rate restore from the last session).
So while I am sharing it below, please don't use it — it's a messy solution, so I'm looking forward to the update :-).
--[[
mpv-svp-restarter
Kill and restart SVPManager on refresh rate change in case it is running,
as it does not re-check refresh rate at runtime on Linux.
Author: Oliver Freyermuth <o.freyermuth@googlemail.com>
Version: 0.1.0
]]--
local mp = require "mp"
local msg = require "mp.msg"
local function check_svp_active()
--[[
Check whether SVPManager is running
]]--
local command = {
name = "subprocess",
playback_only = false,
capture_stdout = true,
capture_stderr = true,
args = {
"pidof", "SVPManager",
},
}
local r = mp.command_native(command)
return (r.status == 0)
end
local function kill_svp()
--[[
Kill all instances of SVPManager
]]--
local command = {
name = "subprocess",
playback_only = false,
capture_stdout = true,
capture_stderr = true,
args = {
"killall", "SVPManager",
},
}
local r = mp.command_native(command)
return r.status
end
local function start_svp()
--[[
Start SVPManager
]]--
local command = {
name = "subprocess",
playback_only = false,
detach = true,
-- wrap in bash to discard output but still return immediately (detached)
args = {
"bash", "-c", "SVPManager > /dev/null 2>&1",
},
}
local r = mp.command_native(command)
return r.status
end
local function restart_svp_if_needed()
--[[
Restart SVP Manager if needed
]]--
if (mp.get_property_native("display-fps") == nil) then
return
end
if not check_svp_active() then
msg.info("SVP not active, not restarting it after refresh rate change.")
return
end
if kill_svp() ~= 0 then
msg.warn("Error killing SVPManager, will not restart it.")
return
end
if start_svp() ~= 0 then
msg.warn("Error starting SVPManager!")
return
end
if not check_svp_active() then
msg.warn("Restarted SVPManager but it is not running, something went wrong.")
end
end
-- kill and restart SVPManager when display fps changes
mp.observe_property("display-fps", "native", restart_svp_if_needed)