1 (edited by olifre 03-09-2025 01:04:40)

Topic: Display refresh rate is not updated when switched on Linux / Wayland

Hi together,

I observe the following problem (may be a configuration problem on my end?):
- Using SVP 4 Linux
- ArchLinux with KDE/Plasma (Wayland) Session, mpv with gpu-next
- SVP is configured to adapt the framerate to the display refresh rate, SVP manager started automatically on login


All works fine, i.e. target FPS is matched to actual display refresh rate.
However, when I switch the display refresh rate within the session (e.g. via `kscreen-doctor` or via `systemsettings` of KDE/Plasma), SVP still uses the old refresh rate as target FPS, even if mpv is restarted afterwards.
The new display refresh rate seems only to be picked up if I quit and restart SVP manager.

Is this expected? Is there any way to make SVP re-check the display refresh rate without restarting SVP manager?

In the end, what I'd like to use is an MPV plugin to switch screen refresh rate automatically (i.e. use 50 Hz for 25 fps content and 48 Hz for 24 fps (23,97 fps) content), but of course that only works if SVP also picks up the changed refresh rate.

Any ideas appreciated, many thanks in advance!

2 (edited by edgedashin Yesterday 03:00:39)

Re: Display refresh rate is not updated when switched on Linux / Wayland

When you change the refresh rate via KDE/Plasma settings, the change will update the editor, but it will not automatically signal all running applications to recheck the setting. The default behavior of SVP will probably be to leave it at the original value until it is manually restarted level devil. I think you should create a mechanism that both triggers the display change and notifies SVP.

Re: Display refresh rate is not updated when switched on Linux / Wayland

Thanks, yes, it seems SVP does sadly not re-check at runtime on Linux (it seems to do that on Windows), so I would need a way to notify it.

Is there some dbus interface or any API of SVP I could notify to make it re-check the refresh rate? Or is the only way to kill SVP manager and restart it?

Re: Display refresh rate is not updated when switched on Linux / Wayland

Have you tried creating a script that integrates changing the refresh rate and restarting the SVP?

Re: Display refresh rate is not updated when switched on Linux / Wayland

there will be a huge update soon

6 (edited by olifre Yesterday 20:19:42)

Re: Display refresh rate is not updated when switched on Linux / Wayland

@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)