Code

Made the xterm title dynamic, added configuration option xterm-title-format
authorKalle Wallin <kaw@linux.se>
Thu, 24 Jun 2004 16:08:24 +0000 (16:08 +0000)
committerKalle Wallin <kaw@linux.se>
Thu, 24 Jun 2004 16:08:24 +0000 (16:08 +0000)
git-svn-id: https://svn.musicpd.org/ncmpc/trunk@1647 09075e82-0dd4-0310-85a5-a0d7c8717e4f

doc/config.sample
doc/ncmpc.1
src/conf.c
src/options.c
src/options.h
src/screen_utils.c

index 755068dcc6f62bca31f6d70321160d1fbada3075..0630296d5bc3c99a7d21bb1513b6f29eceb36692 100644 (file)
@@ -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
 ##
index ac3a65a2136448adcd3ab1246caec11bfb16da6b..7e83ea6c642c2c2ec4c9ed47a4c0a7e1dd36e3fa 100644 (file)
@@ -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 
index 0069489fa08856f2bf9aae46c64be9a28ef70f37..8cf4f5b3a9049fa6b8f67d2062aed40a5b9a9348 100644 (file)
 #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);
index e958e4b957531a96cfcc2c39161b84d8569fc6b5..0aa812204554b1230988fe78948b553834b323ff 100644 (file)
@@ -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;
index 0034cecb5d3a2be0b96f8c91e7de1de14c9117c4..5bc24f38d156a037f2444b2a49b0093f42dd0939 100644 (file)
@@ -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;
index c5efc8e7dfdde993e361beab4f5ede6bc9c79234..c9abc7b1f78a563cbd188006bb17e48d88b2bde8 100644 (file)
@@ -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;
     }
 }