Code

options: configurable timeout for MPD connections
[ncmpc.git] / src / options.c
index 322b66d81622f52009d084b42fefeb6a58c7078b..1b3e9af09cbfb31e7edf7e79ef41d39094214c92 100644 (file)
@@ -60,6 +60,7 @@ options_t options = {
        .audible_bell = true,
        .bell_on_wrap = true,
        .status_message_time = 3,
+       .timeout_ms = DEFAULT_MPD_TIMEOUT,
 #ifndef NCMPC_MINI
        .scroll = DEFAULT_SCROLL,
        .welcome_screen_list = true,
@@ -264,14 +265,12 @@ handle_option(int c, const char *arg)
                g_free(options.key_file);
                options.key_file = g_strdup(arg);
                break;
-#ifndef NDEBUG
-#ifndef NCMPC_MINI
+#if !defined(NDEBUG) && !defined(NCMPC_MINI)
        case 'K': /* --dump-keys */
                read_configuration();
                write_key_bindings(stdout, KEYDEF_WRITE_ALL | KEYDEF_COMMENT_ALL);
                exit(EXIT_SUCCESS);
                break;
-#endif
 #endif
        default:
                fprintf(stderr,"Unknown Option %c = %s\n", c, arg);
@@ -370,9 +369,15 @@ options_init(void)
        options.list_format = g_strdup(DEFAULT_LIST_FORMAT);
        options.status_format = g_strdup(DEFAULT_STATUS_FORMAT);
        options.screen_list = g_strsplit_set(DEFAULT_SCREEN_LIST, " ", 0);
+#ifdef ENABLE_LYRICS_SCREEN
+       options.text_editor = g_strdup(DEFAULT_TEXT_EDITOR);
+#endif
 #ifndef NCMPC_MINI
        options.scroll_sep = g_strdup(DEFAULT_SCROLL_SEP);
 #endif
+       if (getenv("MPD_TIMEOUT") != NULL)
+               /* let libmpdclient parse the environment variable */
+               options.timeout_ms = 0;
 }
 
 void