From b1d16a2300c99fd6bf847b6b3374280f9aafa87d Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 25 May 2020 20:37:37 +0200 Subject: player: add --term-title option This simply printf()s a concatenation of the provided string and the relevant escape sequences. No idea what exactly defines this escape sequence (is it just a xterm thing that is now supported relatively widely?), and this simply uses information provided on the linked github issue. Not much of an advantage over --term-status-msg, though at least this can have a lower update frequency. Also I may consider setting a default value, and then it shouldn't conflict with the status message. Fixes: #1725 --- player/osd.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'player/osd.c') diff --git a/player/osd.c b/player/osd.c index 0e8fd2a0e7..5bf7fa699b 100644 --- a/player/osd.c +++ b/player/osd.c @@ -96,6 +96,21 @@ static void term_osd_update(struct MPContext *mpctx) } } +static void term_osd_update_title(struct MPContext *mpctx) +{ + if (!mpctx->opts->use_terminal) + return; + + char *s = mp_property_expand_escaped_string(mpctx, mpctx->opts->term_title); + if (bstr_equals(bstr0(s), bstr0(mpctx->term_osd_title))) { + talloc_free(s); + return; + } + + mp_msg_set_term_title(mpctx->statusline, s); + mpctx->term_osd_title = talloc_steal(mpctx, s); +} + void term_osd_set_subs(struct MPContext *mpctx, const char *text) { if (mpctx->video_out || !text || !mpctx->opts->subs_rend->sub_visibility) @@ -260,6 +275,7 @@ static void term_osd_print_status_lazy(struct MPContext *mpctx) { struct MPOpts *opts = mpctx->opts; + term_osd_update_title(mpctx); update_window_title(mpctx, false); update_vo_playback_state(mpctx); -- cgit v1.2.3