Skip to content

Commit

Permalink
options: remove --heartbeat-cmd and --heartbeat--interval
Browse files Browse the repository at this point in the history
This mechanism uses system() and shouldn't even exist. x11_common.c has
its own solution for the original problem (disabling Linux DE
screensavers without MPlayer/mpv having to link a dbus lib). If that is
not sufficient, you can create a simple Lua script.

Incidentally fixes #4888.
  • Loading branch information
wm4 committed Sep 18, 2017
1 parent 6b01313 commit 80e3173
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 68 deletions.
3 changes: 3 additions & 0 deletions DOCS/interface-changes.rst
Expand Up @@ -19,6 +19,9 @@ Interface changes

::

--- mpv 0.28.0 ---
- drop previously deprecated --heartbeat-cmd and --heartbeat--interval
options
--- mpv 0.27.0 ---
- drop previously deprecated --field-dominance option
- drop previously deprecated "osd" command
Expand Down
44 changes: 0 additions & 44 deletions DOCS/man/options.rst
Expand Up @@ -2412,50 +2412,6 @@ Window
there is a change in video parameters, video stream or file. This used to
be the default behavior. Currently only affects X11 VOs.

``--heartbeat-cmd=<command>``

.. warning::

This option is redundant with Lua scripting. Further, it shouldn't be
needed for disabling screensaver anyway, since mpv will call
``xdg-screensaver`` when using X11 backend. As a consequence this
option has been deprecated with no direct replacement.

Command that is executed every 30 seconds during playback via *system()* -
i.e. using the shell. The time between the commands can be customized with
the ``--heartbeat-interval`` option. The command is not run while playback
is paused.

.. note::

mpv uses this command without any checking. It is your responsibility to
ensure it does not cause security problems (e.g. make sure to use full
paths if "." is in your path like on Windows). It also only works when
playing video (i.e. not with ``--no-video`` but works with
``--vo=null``).

This can be "misused" to disable screensavers that do not support the
proper X API (see also ``--stop-screensaver``). If you think this is too
complicated, ask the author of the screensaver program to support the
proper X APIs. Note that the ``--stop-screensaver`` does not influence the
heartbeat code at all.

.. admonition:: Example for xscreensaver

``mpv --heartbeat-cmd="xscreensaver-command -deactivate" file``

.. admonition:: Example for GNOME screensaver

``mpv --heartbeat-cmd="gnome-screensaver-command --deactivate" file``


``--heartbeat-interval=<sec>``
Time between ``--heartbeat-cmd`` invocations in seconds (default: 30).

.. note::

This does not affect the normal screensaver operation in any way.

``--no-keepaspect``, ``--keepaspect``
``--no-keepaspect`` will always stretch the video to window size, and will
disable the window manager hints that force the window aspect ratio.
Expand Down
6 changes: 1 addition & 5 deletions options/options.c
Expand Up @@ -565,10 +565,6 @@ const m_option_t mp_opts[] = {
OPT_FLAG("cursor-autohide-fs-only", cursor_autohide_fs, 0),
OPT_FLAG("stop-screensaver", stop_screensaver, UPDATE_SCREENSAVER),

OPT_STRING("heartbeat-cmd", heartbeat_cmd, 0,
.deprecation_message = "use Lua scripting instead"),
OPT_FLOAT("heartbeat-interval", heartbeat_interval, CONF_MIN, 0),

OPT_SUBSTRUCT("", video_equalizer, mp_csp_equalizer_conf, 0),

OPT_FLAG("use-filedir-conf", use_filedir_conf, 0),
Expand Down Expand Up @@ -822,6 +818,7 @@ const m_option_t mp_opts[] = {
OPT_REPLACED("sub-ass-style-override", "sub-ass-override"),
OPT_REMOVED("fs-black-out-screens", NULL),
OPT_REPLACED("sub-paths", "sub-file-paths"),
OPT_REMOVED("heartbeat-cmd", "use Lua scripting instead"),

{0}
};
Expand All @@ -841,7 +838,6 @@ const struct MPOpts mp_default_opts = {
.audio_device = "auto",
.audio_client_name = "mpv",
.wintitle = "${?media-title:${media-title}}${!media-title:No file} - mpv",
.heartbeat_interval = 30.0,
.stop_screensaver = 1,
.cursor_autohide_delay = 1000,
.video_osd = 1,
Expand Down
2 changes: 0 additions & 2 deletions options/options.h
Expand Up @@ -181,8 +181,6 @@ typedef struct MPOpts {
char *status_msg;
char *osd_status_msg;
char *osd_msg[3];
char *heartbeat_cmd;
float heartbeat_interval;
int player_idle_mode;
int consolecontrols;
int playlist_pos;
Expand Down
1 change: 0 additions & 1 deletion player/core.h
Expand Up @@ -386,7 +386,6 @@ typedef struct MPContext {
struct frame_info *past_frames;
int num_past_frames;

double next_heartbeat;
double last_idle_tick;
double next_cache_update;

Expand Down
16 changes: 0 additions & 16 deletions player/playloop.c
Expand Up @@ -685,21 +685,6 @@ int get_cache_buffering_percentage(struct MPContext *mpctx)
return mpctx->demuxer ? mpctx->cache_buffer : -1;
}

static void handle_heartbeat_cmd(struct MPContext *mpctx)
{
#if !HAVE_UWP
struct MPOpts *opts = mpctx->opts;
if (opts->heartbeat_cmd && !mpctx->paused && mpctx->video_out) {
double now = mp_time_sec();
if (mpctx->next_heartbeat <= now) {
mpctx->next_heartbeat = now + opts->heartbeat_interval;
(void)system(opts->heartbeat_cmd);
}
mp_set_timeout(mpctx, mpctx->next_heartbeat - now);
}
#endif
}

static void handle_cursor_autohide(struct MPContext *mpctx)
{
struct MPOpts *opts = mpctx->opts;
Expand Down Expand Up @@ -1089,7 +1074,6 @@ void run_playloop(struct MPContext *mpctx)

handle_cursor_autohide(mpctx);
handle_vo_events(mpctx);
handle_heartbeat_cmd(mpctx);
handle_command_updates(mpctx);

if (mpctx->lavfi) {
Expand Down

0 comments on commit 80e3173

Please sign in to comment.