From 135c11a9e5ff2244cb215ab14798769d859ec998 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 27 Mar 2019 11:50:56 +0100 Subject: [wip] logind console switching --- vttest.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 vttest.c (limited to 'vttest.c') diff --git a/vttest.c b/vttest.c new file mode 100644 index 0000000..2de51c8 --- /dev/null +++ b/vttest.c @@ -0,0 +1,67 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "logind.h" + +/* ---------------------------------------------------------------------- */ + +int main(int argc, char *argv[]) +{ + const char *xdg_seat, *xdg_session_id; + int dbus; + + xdg_seat = getenv("XDG_SEAT"); + xdg_session_id = getenv("XDG_SESSION_ID"); + if (!xdg_seat || !xdg_session_id) { + fprintf(stderr, "session id or seat not found\n"); + exit(1); + } + + fprintf(stderr, "session %s at %s\n", + xdg_session_id, xdg_seat); + if (logind_init(false) != 0) { + fprintf(stderr, "logind init failed\n"); + exit(1); + } + dbus = logind_dbus_fd(); + +#if 0 + logind_open("/dev/dri/card0", 0, NULL); + + const char *xdg_vtnr = getenv("XDG_VTNR"); + if (xdg_vtnr) { + int vt = atoi(xdg_vtnr); + vt++; + fprintf(stderr, "switch to vt %d\n", vt); + logind_switch_vt(vt); + } +#endif + + for (;;) { + fd_set set; + int rc, max; + + max = 0; + FD_ZERO(&set); + FD_SET(dbus, &set); + if (max < dbus) + max = dbus; + + rc = select(max+ 1, &set, NULL, NULL, NULL); + if (rc < 0) + break; + + if (FD_ISSET(dbus, &set)) { + logind_dbus_input(); + } + } + return 0; +} -- cgit