From 6de1590e5902bb44d9f8a84eba52139ac8a308a1 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 21 Oct 2011 20:04:55 +0100 Subject: [PATCH] i3bar: spit out an error on wrong bar id --- i3bar/src/config.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/i3bar/src/config.c b/i3bar/src/config.c index caf13029..179bc464 100644 --- a/i3bar/src/config.c +++ b/i3bar/src/config.c @@ -42,6 +42,22 @@ static int config_map_key_cb(void *params_, const unsigned char *keyVal, unsigne return 1; } +/* + * Parse a null-value (current_workspace) + * + */ +static int config_null_cb(void *params_) { + if (!strcmp(cur_key, "id")) { + /* If 'id' is NULL, the bar config was not found. Error out. */ + ELOG("No such bar config. Use 'i3-msg -t get_bar_config' to get the available configs.\n"); + ELOG("Are you starting i3bar by hand? You should not:\n"); + ELOG("Configure a 'bar' block in your i3 config and i3 will launch i3bar automatically.\n"); + exit(EXIT_FAILURE); + } + + return 1; +} + /* * Parse a string * @@ -143,7 +159,7 @@ static int config_boolean_cb(void *params_, int val) { /* A datastructure to pass all these callbacks to yajl */ static yajl_callbacks outputs_callbacks = { - NULL, + &config_null_cb, &config_boolean_cb, NULL, NULL, -- 2.39.5