Option –heartbeat-cmd was removed: use Lua scripting instead. How to disable xscreensaver in MPV?

Hi!

I tryed to disable xscreensaver when I watch movie on MPV player.

To do it I added to MPV config file a line:
heartbeat-cmd="xscreensaver-command -deactivate >&- 2>&- &"

But when I lounch a movie, it didn’t worked.

So, I tried to add this option directly into the command line and get this error:

Option --heartbeat-cmd was removed: use Lua scripting instead

After that I followed suggestion from mistake above and did following.

1. Created file in home directory with this path (home directory):

~/.config/mpv/scripts/xscreensaver.lua

You probably won’t have such the directories, if so, you need to create them.

2. After this, I added into xscreensaver.lua following code:

local utils = require 'mp.utils'
mp.add_periodic_timer(30, function()
    utils.subprocess({args={"xscreensaver-command", "-deactivate"}})
end)

Saved file and restarted MPV.

Everything worked.

Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *