2 * uxlaunch.c: desktop session starter
4 * (C) Copyright 2009 Intel Corporation
6 * Auke Kok <auke@linux.intel.com>
7 * Arjan van de Ven <arjan@linux.intel.com>
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; version 2
24 * Launch apps that form the user's X session
27 launch_user_session(void)
31 dprintf("entering launch_user_session()");
33 setup_user_environment();
35 /* this needs XDG_* set in environ */
40 /* dbus needs the CK env var */
41 start_dbus_session_bus();
43 /* gconf needs dbus */
48 maybe_start_screensaver();
50 start_desktop_session();
52 /* finally, set local username to be allowed at any time,
53 * which is not depenedent on hostname changes */
54 snprintf(xhost_cmd, 80, "/usr/bin/xhost +SI:localuser:%s",
56 if (system(xhost_cmd) != 0)
57 lprintf("%s failed", xhost_cmd);
59 autostart_desktop_files();
61 dprintf("leaving launch_user_session()");
64 int main(int argc, char **argv)
68 * Do the things that need root privs first,
69 * then switch to the final user ASAP.
71 * Once we're at the target user ID, we need
72 * to start X since that's the critical element
75 * While X is starting, we can do the things
76 * that we need to do as the user UID, but that
77 * don't need X running yet.
79 * We then wait for X to signal that it's ready
82 * Once X is running, we set up the ConsoleKit session,
83 * check if the screensaver needs to lock the screen
84 * and then start the window manager.
85 * After that we go over the autostart .desktop files
86 * to launch the various autostart processes....
90 get_options(argc, argv);
93 dprintf("X session only: skipping major parts of setup");
94 launch_user_session();
95 wait_for_session_exit();
104 #ifdef ENABLE_CHOOSER
105 if (chooser[0] != '\0')
109 #ifdef ENABLE_ECRYPTFS
117 #ifdef WITH_CONSOLEKIT
118 setup_consolekit_session();
124 * BUG: udev is sometimes not done when we go and start Xorg,
125 * which results in the mouse/kbd not working. To work around this
126 * we call udevadm settle and force the system to wait for
127 * device probing to complete, which may be a long time
129 dprintf("Waiting for udev to settle for 10 seconds max...");
130 if (system("/usr/bin/udevadm settle --timeout 10") != EXIT_SUCCESS)
131 lprintf("udevadm settle bash returned an error");
136 * These steps don't need X running
137 * so can happen while X is talking to the
142 launch_user_session();
145 * we do this now to make sure dbus etc are not spawning
147 * tasks at non-oomkillable priorities
150 oom_adj(xpid, -1000);
151 oom_adj(session_pid, -1000);
152 oom_adj(getpid(), -1000);
155 * The desktop session runs here
163 // close_consolekit_session();
165 stop_dbus_session_bus();
169 unlink(xauth_cookie_file);
171 /* Make sure that we clean up after ourselves */
174 lprintf("Terminating uxlaunch and all children");