summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-05-25 20:37:37 +0200
committerwm4 <wm4@nowhere>2020-05-25 20:39:37 +0200
commitb1d16a2300c99fd6bf847b6b3374280f9aafa87d (patch)
tree8fcddcfbd8a03f25d462a437fd32edd5b610a4ab /common
parentb83bdd1d17cc90b4d8cd2a32321cd7c5cc306422 (diff)
downloadmpv-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 'common')
-rw-r--r--common/msg.c10
-rw-r--r--common/msg_control.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/common/msg.c b/common/msg.c
index 0d1c165222..7f8754b308 100644
--- a/common/msg.c
+++ b/common/msg.c
@@ -230,6 +230,16 @@ void mp_msg_flush_status_line(struct mp_log *log)
}
}
+void mp_msg_set_term_title(struct mp_log *log, const char *title)
+{
+ if (log->root && title) {
+ // Lock because printf to terminal is not necessarily atomic.
+ pthread_mutex_lock(&log->root->lock);
+ fprintf(stderr, "\e]0;%s\007", title);
+ pthread_mutex_unlock(&log->root->lock);
+ }
+}
+
bool mp_msg_has_status_line(struct mpv_global *global)
{
struct mp_log_root *root = global->log->root;
diff --git a/common/msg_control.h b/common/msg_control.h
index 8d9c9e33d2..2179881a04 100644
--- a/common/msg_control.h
+++ b/common/msg_control.h
@@ -14,6 +14,7 @@ bool mp_msg_has_log_file(struct mpv_global *global);
void mp_msg_set_early_logging(struct mpv_global *global, bool enable);
void mp_msg_flush_status_line(struct mp_log *log);
+void mp_msg_set_term_title(struct mp_log *log, const char *title);
struct mp_log_buffer_entry {
char *prefix;