diff --git a/src/kmscon_conf.c b/src/kmscon_conf.c index d0006b4..65b7c53 100644 --- a/src/kmscon_conf.c +++ b/src/kmscon_conf.c @@ -375,28 +375,6 @@ static int aftercheck_help(struct conf_option *opt, int argc, char **argv, return 0; } -static int aftercheck_seats(struct conf_option *opt, int argc, char **argv, - int idx) -{ - struct kmscon_conf_t *conf = KMSCON_CONF_FROM_FIELD(opt->mem, seats); - - if (conf->seats[0] && - !conf->seats[1] && - !strcmp(conf->seats[0], "all")) - conf->all_seats = true; - - return 0; -} - -static int copy_seats(struct conf_option *opt, const struct conf_option *src) -{ - struct kmscon_conf_t *conf = KMSCON_CONF_FROM_FIELD(opt->mem, seats); - struct kmscon_conf_t *s = KMSCON_CONF_FROM_FIELD(src->mem, seats); - - conf->all_seats = s->all_seats; - return 0; -} - static int aftercheck_drm(struct conf_option *opt, int argc, char **argv, int idx) { @@ -470,7 +448,7 @@ int kmscon_conf_new(struct conf_ctx **out) /* Seat Options */ CONF_OPTION(0, 0, "vt", &conf_vt, NULL, NULL, NULL, &conf->vt, NULL), CONF_OPTION_BOOL('s', "switchvt", &conf->switchvt, true), - CONF_OPTION_STRING_LIST_FULL(0, "seats", aftercheck_seats, copy_seats, NULL, &conf->seats, def_seats), + CONF_OPTION_STRING_LIST(0, "seats", &conf->seats, def_seats), /* Session Options */ CONF_OPTION_UINT(0, "session-max", &conf->session_max, 50), diff --git a/src/kmscon_conf.h b/src/kmscon_conf.h index eb3db9b..cbb2b6e 100644 --- a/src/kmscon_conf.h +++ b/src/kmscon_conf.h @@ -57,8 +57,6 @@ struct kmscon_conf_t { bool switchvt; /* seats */ char **seats; - /* true if \seats is "all" */ - bool all_seats; /* Session Options */ /* sessions */ diff --git a/src/kmscon_main.c b/src/kmscon_main.c index 970bc91..12d59e5 100644 --- a/src/kmscon_main.c +++ b/src/kmscon_main.c @@ -118,7 +118,7 @@ static int app_seat_new(struct kmscon_app *app, struct app_seat **out, bool found; found = false; - if (app->conf->all_seats) { + if (shl_string_list_is(app->conf->seats, "all")) { found = true; } else { for (i = 0; app->conf->seats[i]; ++i) { diff --git a/src/shl_misc.h b/src/shl_misc.h index eb21ad4..f05434d 100644 --- a/src/shl_misc.h +++ b/src/shl_misc.h @@ -189,6 +189,16 @@ static inline int shl_dup_array(char ***out, char **argv) return shl_dup_array_size(out, argv, i); } +/* returns true if the string-list contains only a single entry \entry */ +static inline bool shl_string_list_is(char **list, const char *entry) +{ + if (!list || !entry) + return false; + if (!list[0] || list[1]) + return false; + return !strcmp(list[0], entry); +} + /* TODO: xkbcommon should provide these flags! * We currently copy them into each library API we use so we need to keep * them in sync. Currently, they're used in uterm-input and tsm-vte. */