Allow to validate the config file without X.
We're going to call parse_configuration() very early if -C is given on the command line. Instead of the previous "only_check_config", which has been a global variable, we now simply pass use_nagbar as false if we're just validating. This causes the whole parsing to run without X and of course without starting nagbar and displaying the errors to standard out/error instead. The return code of parse_configuration() is now a boolean which represents whether an error occured during parsing and the programs exit code is returned accordingly. Although the config parser still has a lot of side-effects, we now can parse without the need to have an XCB connection. A nicer implementation would be to just set the new font and load it just after we're done parsing, but to ensure we don't break functionality we just load a dummy FONT_TYPE_NONE if XCB isn't available. The main reason for going this route is that it's a bit difficult to test fonts in a distribution agnostic way without bundling fonts with i3 (or Xdummy to be more exact). Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
committed by
Michael Stapelberg
parent
beba1633ac
commit
9058fc44e6
@ -840,7 +840,7 @@ static char *migrate_config(char *input, off_t size) {
|
||||
* parse_config and possibly launching i3-nagbar.
|
||||
*
|
||||
*/
|
||||
void parse_file(const char *f) {
|
||||
bool parse_file(const char *f, bool use_nagbar) {
|
||||
SLIST_HEAD(variables_head, Variable) variables = SLIST_HEAD_INITIALIZER(&variables);
|
||||
int fd, ret, read_bytes = 0;
|
||||
struct stat stbuf;
|
||||
@ -1000,7 +1000,7 @@ void parse_file(const char *f) {
|
||||
|
||||
check_for_duplicate_bindings(context);
|
||||
|
||||
if (context->has_errors || context->has_warnings) {
|
||||
if (use_nagbar && (context->has_errors || context->has_warnings)) {
|
||||
ELOG("FYI: You are using i3 version " I3_VERSION "\n");
|
||||
if (version == 3)
|
||||
ELOG("Please convert your configfile first, then fix any remaining errors (see above).\n");
|
||||
@ -1030,6 +1030,8 @@ void parse_file(const char *f) {
|
||||
free(pageraction);
|
||||
}
|
||||
|
||||
bool has_errors = context->has_errors;
|
||||
|
||||
FREE(context->line_copy);
|
||||
free(context);
|
||||
free(new);
|
||||
@ -1042,6 +1044,8 @@ void parse_file(const char *f) {
|
||||
SLIST_REMOVE_HEAD(&variables, variables);
|
||||
FREE(current);
|
||||
}
|
||||
|
||||
return !has_errors;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user