Code

added option to disable the status line clock display
authorPaul Collins <paul@burly.ondioline.org>
Thu, 1 Jan 2009 21:54:04 +0000 (22:54 +0100)
committerMax Kellermann <max@duempel.org>
Thu, 1 Jan 2009 21:54:04 +0000 (22:54 +0100)
I already have a clock, and I don't need ncmpc showing me another one.

This patch adds command line options and a config file item to allow the
user to flexibly enable or disable the clock.

[mk: patch from http://bugs.debian.org/510392; removed command line
options]

src/conf.c
src/options.c
src/options.h
src/screen.c

index 38d5089540e49369a25c97cca9c0030d11e95a63..67d048ae6972eb43dec841e85ef56d5e2e588e2d 100644 (file)
@@ -72,6 +72,7 @@
 #define CONF_SCROLL_SEP "scroll-sep"
 #define CONF_VISIBLE_BITRATE "visible-bitrate"
 #define CONF_WELCOME_SCREEN_LIST "welcome-screen-list"
+#define CONF_DISPLAY_TIME "display-time"
 
 static bool
 str2bool(char *str)
@@ -448,7 +449,13 @@ parse_line(char *line)
        else if (!strcasecmp(CONF_SCROLL_SEP, name)) {
                g_free(options.scroll_sep);
                options.scroll_sep = get_format(value);
-       } else
+       } else if (!strcasecmp(CONF_DISPLAY_TIME, name))
+#ifdef NCMPC_MINI
+               {}
+#else
+               options.display_time = str2bool(value);
+#endif
+       else
                match_found = false;
 
        if (!match_found)
index 5bb5fbadd7f20fd652706c211bbc9e42aeb250de..3f784d11cc9c00ab23b84a1be23af8f7690790ba 100644 (file)
@@ -61,6 +61,7 @@ options_t options = {
 #ifndef NCMPC_MINI
        .scroll = DEFAULT_SCROLL,
        .welcome_screen_list = true,
+       .display_time = true,
 #endif
 };
 
index 671107a76dfe389504aae741581a0ae0eacfc97a..c48d1b39044ff2495d9d239c66e7902913dd54b7 100644 (file)
@@ -69,6 +69,7 @@ typedef struct {
        bool scroll;
        bool visible_bitrate;
        bool welcome_screen_list;
+       bool display_time;
 #endif
 } options_t;
 
index 1f44f73982a80a5eaa02a7635dd1e0c27c369f74..924cf4bd8149be56272366f0cdb9fc13734c081b 100644 (file)
@@ -338,10 +338,12 @@ paint_status_window(mpdclient_t *c)
                }
 #ifndef NCMPC_MINI
        } else {
-               time_t timep;
+               if (options.display_time) {
+                       time_t timep;
 
-               time(&timep);
-               strftime(screen.buf, screen.buf_size, "%X ",localtime(&timep));
+                       time(&timep);
+                       strftime(screen.buf, screen.buf_size, "%X ",localtime(&timep));
+               }
 #endif
        }