X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fconky.c;h=b08df7c0ccbc1b0a6a4418044cd6493c71c68048;hb=a9e5820a3454f27cdb388f988f21d154aa2c9cce;hp=50cbb2ade5d57e72982644a7fabacf9d641f9be8;hpb=99fd8ef38080a873bee67cd7742e5c67048aeb63;p=monky diff --git a/src/conky.c b/src/conky.c index 50cbb2a..b08df7c 100644 --- a/src/conky.c +++ b/src/conky.c @@ -320,7 +320,8 @@ static int text_width, text_height; /* alignments */ enum alignment { - TOP_LEFT = 1, + ALIGNMENT_ERROR, + TOP_LEFT, TOP_RIGHT, TOP_MIDDLE, BOTTOM_LEFT, @@ -3947,7 +3948,7 @@ static void main_loop(void) #endif /* HAVE_LUA */ g_signal_pending = 0; } - clean_up(NULL, NULL); + clean_up(current_mail_spool, NULL); #ifdef HAVE_SYS_INOTIFY_H if (inotify_fd != -1) { @@ -4153,7 +4154,7 @@ static enum alignment string_to_alignment(const char *s) } else if (strcasecmp(s, "none") == EQUAL) { return NONE; } - return TOP_LEFT; + return ALIGNMENT_ERROR; } #endif /* X11 */ @@ -4506,6 +4507,29 @@ static int do_config_step(int *line, FILE *fp, char *buf, char **name, char **va return 0; } +#ifdef X11 +void setalignment(int* text_alignment, unsigned int windowtype, const char* value, const char *f, int line, char setbyconffile) { +#ifdef OWN_WINDOW + if (windowtype == TYPE_DOCK) { + NORM_ERR("alignment is disabled when own_window_type is dock"); + } else +#endif /*OWN_WINDOW */ + if (value) { + int a = string_to_alignment(value); + + if (a <= 0) { + if(setbyconffile == true) { + CONF_ERR; + } else NORM_ERR("'%s' is not a alignment setting", value); + } else { + *text_alignment = a; + } + } else if(setbyconffile == true) { + CONF_ERR; + } +} +#endif /* X11 */ + char load_config_file(const char *f) { int line = 0; @@ -4549,22 +4573,7 @@ char load_config_file(const char *f) } } CONF("alignment") { -#ifdef OWN_WINDOW - if (window.type == TYPE_DOCK) - ; - else -#endif /*OWN_WINDOW */ - if (value) { - int a = string_to_alignment(value); - - if (a <= 0) { - CONF_ERR; - } else { - text_alignment = a; - } - } else { - CONF_ERR; - } + setalignment(&text_alignment, window.type, value, f, line, true); } CONF("background") { fork_to_background = string_to_bool(value); @@ -5553,6 +5562,7 @@ static const char *getopt_string = "vVqdDt:u:i:hc:p:" static const struct option longopts[] = { { "help", 0, NULL, 'h' }, { "version", 0, NULL, 'V' }, + { "quiet", 0, NULL, 'q' }, { "debug", 0, NULL, 'D' }, { "config", 1, NULL, 'c' }, #ifdef CONFIG_OUTPUT @@ -5572,15 +5582,62 @@ static const struct option longopts[] = { { "window-id", 1, NULL, 'w' }, #endif /* X11 */ { "text", 1, NULL, 't' }, - { "interval", 0, NULL, 'u' }, - { "pause", 0, NULL, 'p' }, + { "interval", 1, NULL, 'u' }, + { "pause", 1, NULL, 'p' }, { 0, 0, 0, 0 } }; +void set_current_config() { + /* check if specified config file is valid */ + if (current_config) { + struct stat sb; + if (stat(current_config, &sb) || + (!S_ISREG(sb.st_mode) && !S_ISLNK(sb.st_mode))) { + NORM_ERR("invalid configuration file '%s'\n", current_config); + free(current_config); + current_config = 0; + } + } + + /* load current_config, CONFIG_FILE or SYSTEM_CONFIG_FILE */ + + if (!current_config) { + /* load default config file */ + char buf[DEFAULT_TEXT_BUFFER_SIZE]; + FILE *fp; + + /* Try to use personal config file first */ + to_real_path(buf, CONFIG_FILE); + if (buf[0] && (fp = fopen(buf, "r"))) { + current_config = strndup(buf, max_user_text); + fclose(fp); + } + + /* Try to use system config file if personal config not readable */ + if (!current_config && (fp = fopen(SYSTEM_CONFIG_FILE, "r"))) { + current_config = strndup(SYSTEM_CONFIG_FILE, max_user_text); + fclose(fp); + } + + /* No readable config found */ + if (!current_config) { +#define NOCFGFILEFOUND "no readable personal or system-wide config file found" +#ifdef BUILD_BUILTIN_CONFIG + current_config = strdup("==builtin=="); + NORM_ERR(NOCFGFILEFOUND + ", using builtin default"); +#else + CRIT_ERR(NULL, NULL, NOCFGFILEFOUND); +#endif /* ! CONF_OUTPUT */ + } + } +} + void initialisation(int argc, char **argv) { struct sigaction act, oact; set_default_configurations(); + set_current_config(); load_config_file(current_config); currentconffile = conftree_add(currentconffile, current_config); @@ -5637,7 +5694,7 @@ void initialisation(int argc, char **argv) { set_first_font(optarg); break; case 'a': - text_alignment = string_to_alignment(optarg); + setalignment(&text_alignment, window.type, optarg, NULL, 0, false); break; #ifdef OWN_WINDOW @@ -5862,48 +5919,7 @@ int main(int argc, char **argv) } } - /* check if specified config file is valid */ - if (current_config) { - struct stat sb; - if (stat(current_config, &sb) || - (!S_ISREG(sb.st_mode) && !S_ISLNK(sb.st_mode))) { - NORM_ERR("invalid configuration file '%s'\n", current_config); - free(current_config); - current_config = 0; - } - } - - /* load current_config, CONFIG_FILE or SYSTEM_CONFIG_FILE */ - - if (!current_config) { - /* load default config file */ - char buf[DEFAULT_TEXT_BUFFER_SIZE]; - FILE *fp; - - /* Try to use personal config file first */ - to_real_path(buf, CONFIG_FILE); - if (buf[0] && (fp = fopen(buf, "r"))) { - current_config = strndup(buf, max_user_text); - fclose(fp); - } - - /* Try to use system config file if personal config not readable */ - if (!current_config && (fp = fopen(SYSTEM_CONFIG_FILE, "r"))) { - current_config = strndup(SYSTEM_CONFIG_FILE, max_user_text); - fclose(fp); - } - - /* No readable config found */ - if (!current_config) { -#ifdef CONFIG_OUTPUT - current_config = strdup("==builtin=="); - NORM_ERR("no readable personal or system-wide config file found," - " using builtin default"); -#else - CRIT_ERR(NULL, NULL, "no readable personal or system-wide config file found"); -#endif /* ! CONF_OUTPUT */ - } - } + set_current_config(); #ifdef XOAP /* Load xoap keys, if existing */