9 #include <glib-object.h>
14 static GKeyFile *config;
19 status_notify ("SESSION %s TERMINATE SIGNAL=%d", getenv ("DISPLAY"), signum);
24 request_cb (const gchar *request)
28 r = g_strdup_printf ("SESSION %s LOGOUT", getenv ("DISPLAY"));
29 if (strcmp (request, r) == 0)
33 r = g_strdup_printf ("SESSION %s CRASH", getenv ("DISPLAY"));
34 if (strcmp (request, r) == 0)
35 kill (getpid (), SIGSEGV);
38 r = g_strdup_printf ("SESSION %s LOCK-SEAT", getenv ("DISPLAY"));
39 if (strcmp (request, r) == 0)
41 g_dbus_connection_call_sync (g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL),
42 "org.freedesktop.DisplayManager",
43 getenv ("XDG_SEAT_PATH"),
44 "org.freedesktop.DisplayManager.Seat",
47 G_VARIANT_TYPE ("()"),
48 G_DBUS_CALL_FLAGS_NONE,
52 status_notify ("SESSION %s LOCK-SEAT", getenv ("DISPLAY"));
56 r = g_strdup_printf ("SESSION %s LOCK-SESSION", getenv ("DISPLAY"));
57 if (strcmp (request, r) == 0)
59 g_dbus_connection_call_sync (g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL),
60 "org.freedesktop.DisplayManager",
61 getenv ("XDG_SESSION_PATH"),
62 "org.freedesktop.DisplayManager.Session",
65 G_VARIANT_TYPE ("()"),
66 G_DBUS_CALL_FLAGS_NONE,
70 status_notify ("SESSION %s LOCK-SESSION", getenv ("DISPLAY"));
74 r = g_strdup_printf ("SESSION %s WRITE-STDOUT TEXT=", getenv ("DISPLAY"));
75 if (g_str_has_prefix (request, r))
76 g_print ("%s\n", request + strlen (r));
79 r = g_strdup_printf ("SESSION %s WRITE-STDERR TEXT=", getenv ("DISPLAY"));
80 if (g_str_has_prefix (request, r))
81 g_printerr ("%s\n", request + strlen (r));
84 r = g_strdup_printf ("SESSION %s READ-XSESSION-ERRORS", getenv ("DISPLAY"));
85 if (strcmp (request, r) == 0)
90 if (g_file_get_contents (".xsession-errors", &contents, NULL, &error))
91 status_notify ("SESSION %s READ-XSESSION-ERRORS TEXT=%s", getenv ("DISPLAY"), contents);
93 status_notify ("SESSION %s READ-XSESSION-ERRORS ERROR=%s", getenv ("DISPLAY"), error->message);
94 g_clear_error (&error);
100 main (int argc, char **argv)
103 xcb_connection_t *connection;
105 signal (SIGINT, quit_cb);
106 signal (SIGTERM, quit_cb);
110 loop = g_main_loop_new (NULL, FALSE);
112 status_connect (request_cb);
115 status_notify ("SESSION %s START NAME=%s USER=%s", getenv ("DISPLAY"), argv[1], getenv ("USER"));
117 status_notify ("SESSION %s START USER=%s", getenv ("DISPLAY"), getenv ("USER"));
119 config = g_key_file_new ();
120 if (g_getenv ("LIGHTDM_TEST_CONFIG"))
121 g_key_file_load_from_file (config, g_getenv ("LIGHTDM_TEST_CONFIG"), G_KEY_FILE_NONE, NULL);
123 connection = xcb_connect (NULL, NULL);
125 if (xcb_connection_has_error (connection))
127 status_notify ("SESSION %s CONNECT-XSERVER-ERROR", getenv ("DISPLAY"));
131 status_notify ("SESSION %s CONNECT-XSERVER", getenv ("DISPLAY"));
133 g_main_loop_run (loop);