diff --git a/docs/man/kmscon.xml b/docs/man/kmscon.xml index 3db1ab9..bc8a207 100644 --- a/docs/man/kmscon.xml +++ b/docs/man/kmscon.xml @@ -162,7 +162,8 @@ List of seats kmscon will run on. Use 'all' to make kmscon run on all seats. Use 'all,' to make kmscon run on a seat called - 'all' (empty entries are ignored). (default: "seat0") + 'all' (empty entries are ignored). Use 'current' to make kmscon + run on the current seat. (default: "current") If kmscon runs on multiple seats, all seats are independent of each other. You can either run a different kmscon process on diff --git a/src/kmscon_conf.c b/src/kmscon_conf.c index 95158c8..242a576 100644 --- a/src/kmscon_conf.c +++ b/src/kmscon_conf.c @@ -73,8 +73,7 @@ static void print_help() "Seat Options:\n" "\t --vt [auto] Select which VT to run on\n" "\t --switchvt [on] Automatically switch to VT\n" - "\t --seats [seat0] Select seats or pass 'all' to make\n" - "\t kmscon run on all seats\n" + "\t --seats [current] Select seats to run on\n" "\n" "Session Options:\n" "\t --session-max [50] Maximum number of sessions\n" @@ -494,7 +493,7 @@ static int aftercheck_listen(struct conf_option *opt, int argc, char **argv, * speeds up config-parser considerably. */ -static char *def_seats[] = { "seat0", NULL }; +static char *def_seats[] = { "current", NULL }; static struct conf_grab def_grab_scroll_up = CONF_SINGLE_GRAB(SHL_SHIFT_MASK, XKB_KEY_Up); diff --git a/src/kmscon_conf.h b/src/kmscon_conf.h index 55e3558..71cc453 100644 --- a/src/kmscon_conf.h +++ b/src/kmscon_conf.h @@ -156,6 +156,11 @@ int kmscon_conf_load_main(struct conf_ctx *ctx, int argc, char **argv); int kmscon_conf_load_seat(struct conf_ctx *ctx, const struct conf_ctx *main, const char *seat); +static inline bool kmscon_conf_is_current_seat(struct kmscon_conf_t *conf) +{ + return conf && shl_string_list_is(conf->seats, "current"); +} + static inline bool kmscon_conf_is_all_seats(struct kmscon_conf_t *conf) { return conf && shl_string_list_is(conf->seats, "all"); diff --git a/src/kmscon_main.c b/src/kmscon_main.c index 06186a4..cd6dc70 100644 --- a/src/kmscon_main.c +++ b/src/kmscon_main.c @@ -155,6 +155,7 @@ static int app_seat_new(struct kmscon_app *app, const char *sname, int ret; unsigned int i, types; bool found; + char *cseat; if (app->exiting) return -EBUSY; @@ -162,6 +163,12 @@ static int app_seat_new(struct kmscon_app *app, const char *sname, found = false; if (kmscon_conf_is_all_seats(app->conf)) { found = true; + } else if (kmscon_conf_is_current_seat(app->conf)) { + cseat = getenv("XDG_SEAT"); + if (!cseat) + cseat = "seat0"; + if (!strcmp(cseat, sname)) + found = true; } else { for (i = 0; app->conf->seats[i]; ++i) { if (!strcmp(app->conf->seats[i], sname)) {