kmscon: add --seats=current option
This option uses XDG_SEAT to determine the current seat. If this is NULL, we fall back to "seat0". Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
parent
b78244e1ab
commit
6e8fb5aa0d
@ -162,7 +162,8 @@
|
||||
<listitem>
|
||||
<para>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")</para>
|
||||
'all' (empty entries are ignored). Use 'current' to make kmscon
|
||||
run on the current seat. (default: "current")</para>
|
||||
|
||||
<para>If kmscon runs on multiple seats, all seats are independent of
|
||||
each other. You can either run a different kmscon process on
|
||||
|
@ -73,8 +73,7 @@ static void print_help()
|
||||
"Seat Options:\n"
|
||||
"\t --vt <vt> [auto] Select which VT to run on\n"
|
||||
"\t --switchvt [on] Automatically switch to VT\n"
|
||||
"\t --seats <list,of,seats> [seat0] Select seats or pass 'all' to make\n"
|
||||
"\t kmscon run on all seats\n"
|
||||
"\t --seats <list,of,seats> [current] Select seats to run on\n"
|
||||
"\n"
|
||||
"Session Options:\n"
|
||||
"\t --session-max <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);
|
||||
|
@ -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");
|
||||
|
@ -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)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user