diff options
-rw-r--r-- | doc/config.sample | 3 | ||||
-rw-r--r-- | doc/ncmpc.1 | 9 | ||||
-rw-r--r-- | src/conf.c | 8 | ||||
-rw-r--r-- | src/options.c | 1 | ||||
-rw-r--r-- | src/options.h | 1 | ||||
-rw-r--r-- | src/screen_utils.c | 21 |
6 files changed, 32 insertions, 11 deletions
diff --git a/doc/config.sample b/doc/config.sample index 755068dcc..0630296d5 100644 --- a/doc/config.sample +++ b/doc/config.sample @@ -29,6 +29,9 @@ ## change the xterm title #set-xterm-title = no +## xterm title format +#xterm-title-format = "ncmpc: [ %name%|[%artist% - ]%title%|%file%]" + ## ## Color configuration ## diff --git a/doc/ncmpc.1 b/doc/ncmpc.1 index ac3a65a21..7e83ea6c6 100644 --- a/doc/ncmpc.1 +++ b/doc/ncmpc.1 @@ -84,15 +84,18 @@ Sound audible bell on alerts. .B visible\-bell = yes|no Visible bell on alerts. .TP -.B set\-xterm\-title = yes|no -Change the XTerm title (ncmpc will not restore the title). -.TP .B list\-format = SONG FORMAT The format used to display songs in the main window. .TP .B status\-format = SONG FORMAT The format used to display songs on the status line. .TP +.B set\-xterm\-title = yes|no +Change the XTerm title (ncmpc will not restore the title). +.TP +.B xterm\-title\-format = SONG FORMAT +The format used to for the xterm title when ncmpc is playing. +.TP .B enable\-colors = yes|no Enable/disable colors. .TP diff --git a/src/conf.c b/src/conf.c index 0069489fa..8cf4f5b3a 100644 --- a/src/conf.c +++ b/src/conf.c @@ -53,12 +53,14 @@ #define CONF_COLOR_DEFINITION "colordef" #define CONF_LIST_FORMAT "list-format" #define CONF_STATUS_FORMAT "status-format" +#define CONF_XTERM_TITLE_FORMAT "xterm-title-format" #define CONF_LIST_WRAP "wrap-around" #define CONF_FIND_WRAP "find-wrap" #define CONF_AUDIBLE_BELL "audible-bell" #define CONF_VISIBLE_BELL "visible-bell" #define CONF_XTERM_TITLE "set-xterm-title" + /* Deprecated - configuration field names */ #define OLD_CONF_ENABLE_COLORS "enable_colors" #define OLD_CONF_AUTO_CENTER "auto_center" @@ -515,6 +517,12 @@ read_rc_file(char *filename, options_t *options) g_free(options->status_format); options->status_format = get_format(value); } + /* xterm title format string */ + else if( !strcasecmp(CONF_XTERM_TITLE_FORMAT, name) ) + { + g_free(options->xterm_title_format); + options->xterm_title_format = get_format(value); + } else if( !strcasecmp(CONF_LIST_WRAP, name) ) { options->list_wrap = str2bool(value); diff --git a/src/options.c b/src/options.c index e958e4b95..0aa812204 100644 --- a/src/options.c +++ b/src/options.c @@ -175,6 +175,7 @@ options_init( void ) options.list_format = NULL; options.status_format = NULL; + options.xterm_title_format = NULL; options.reconnect = TRUE; options.find_wrap = TRUE; diff --git a/src/options.h b/src/options.h index 0034cecb5..5bc24f38d 100644 --- a/src/options.h +++ b/src/options.h @@ -11,6 +11,7 @@ typedef struct char *key_file; char *list_format; char *status_format; + char *xterm_title_format; int port; gboolean reconnect; gboolean debug; diff --git a/src/screen_utils.c b/src/screen_utils.c index c5efc8e7d..c9abc7b1f 100644 --- a/src/screen_utils.c +++ b/src/screen_utils.c @@ -216,14 +216,19 @@ set_xterm_title(char *format, ...) /* the current xterm title exists under the WM_NAME property */ /* and can be retreived with xprop -id $WINDOWID */ - if( options.enable_xterm_title && g_getenv("WINDOWID") ) + if( options.enable_xterm_title ) { - char buffer[512]; - va_list ap; - - va_start(ap,format); - vsnprintf(buffer,sizeof(buffer),format,ap); - va_end(ap); - printf("%c]0;%s%c", '\033', buffer, '\007'); + if( g_getenv("WINDOWID") ) + { + char buffer[512]; + va_list ap; + + va_start(ap,format); + vsnprintf(buffer,sizeof(buffer),format,ap); + va_end(ap); + printf("%c]0;%s%c", '\033', buffer, '\007'); + } + else + options.enable_xterm_title = FALSE; } } |