diff options
author | wm4 <wm4@nowhere> | 2020-05-25 20:37:37 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2020-05-25 20:39:37 +0200 |
commit | b1d16a2300c99fd6bf847b6b3374280f9aafa87d (patch) | |
tree | 8fcddcfbd8a03f25d462a437fd32edd5b610a4ab /player | |
parent | b83bdd1d17cc90b4d8cd2a32321cd7c5cc306422 (diff) | |
download | mpv-b1d16a2300c99fd6bf847b6b3374280f9aafa87d.tar.bz2 mpv-b1d16a2300c99fd6bf847b6b3374280f9aafa87d.tar.xz |
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
Diffstat (limited to 'player')
-rw-r--r-- | player/core.h | 1 | ||||
-rw-r--r-- | player/osd.c | 16 |
2 files changed, 17 insertions, 0 deletions
diff --git a/player/core.h b/player/core.h index 55c8f514db..8bafb707f4 100644 --- a/player/core.h +++ b/player/core.h @@ -264,6 +264,7 @@ typedef struct MPContext { char *term_osd_status; char *term_osd_subs; char *term_osd_contents; + char *term_osd_title; char *last_window_title; struct voctrl_playback_state vo_playback_state; 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); |