]> git.sur5r.net Git - i3/i3/blob - src/main.c
Change the root window cursor to 'watch' during startups
[i3/i3] / src / main.c
1 /*
2  * vim:ts=4:sw=4:expandtab
3  */
4 #include <ev.h>
5 #include <fcntl.h>
6 #include <sys/types.h>
7 #include <sys/socket.h>
8 #include <sys/un.h>
9 #include "all.h"
10
11 #include "sd-daemon.h"
12
13 static int xkb_event_base;
14
15 int xkb_current_group;
16
17 extern Con *focused;
18
19 char **start_argv;
20
21 xcb_connection_t *conn;
22 /* The screen (0 when you are using DISPLAY=:0) of the connection 'conn' */
23 int conn_screen;
24
25 /* Display handle for libstartup-notification */
26 SnDisplay *sndisplay;
27
28 /* The last timestamp we got from X11 (timestamps are included in some events
29  * and are used for some things, like determining a unique ID in startup
30  * notification). */
31 xcb_timestamp_t last_timestamp = XCB_CURRENT_TIME;
32
33 xcb_screen_t *root_screen;
34 xcb_window_t root;
35 uint8_t root_depth;
36
37 struct ev_loop *main_loop;
38
39 xcb_key_symbols_t *keysyms;
40
41 /* Those are our connections to X11 for use with libXcursor and XKB */
42 Display *xlibdpy, *xkbdpy;
43
44 /* The list of key bindings */
45 struct bindings_head *bindings;
46
47 /* The list of exec-lines */
48 struct autostarts_head autostarts = TAILQ_HEAD_INITIALIZER(autostarts);
49
50 /* The list of exec_always lines */
51 struct autostarts_always_head autostarts_always = TAILQ_HEAD_INITIALIZER(autostarts_always);
52
53 /* The list of assignments */
54 struct assignments_head assignments = TAILQ_HEAD_INITIALIZER(assignments);
55
56 /* The list of workspace assignments (which workspace should end up on which
57  * output) */
58 struct ws_assignments_head ws_assignments = TAILQ_HEAD_INITIALIZER(ws_assignments);
59
60 /* We hope that those are supported and set them to true */
61 bool xcursor_supported = true;
62 bool xkb_supported = true;
63
64 /*
65  * This callback is only a dummy, see xcb_prepare_cb and xcb_check_cb.
66  * See also man libev(3): "ev_prepare" and "ev_check" - customise your event loop
67  *
68  */
69 static void xcb_got_event(EV_P_ struct ev_io *w, int revents) {
70     /* empty, because xcb_prepare_cb and xcb_check_cb are used */
71 }
72
73 /*
74  * Flush before blocking (and waiting for new events)
75  *
76  */
77 static void xcb_prepare_cb(EV_P_ ev_prepare *w, int revents) {
78     xcb_flush(conn);
79 }
80
81 /*
82  * Instead of polling the X connection socket we leave this to
83  * xcb_poll_for_event() which knows better than we can ever know.
84  *
85  */
86 static void xcb_check_cb(EV_P_ ev_check *w, int revents) {
87     xcb_generic_event_t *event;
88
89     while ((event = xcb_poll_for_event(conn)) != NULL) {
90         if (event->response_type == 0) {
91             if (event_is_ignored(event->sequence, 0))
92                 DLOG("Expected X11 Error received for sequence %x\n", event->sequence);
93             else {
94                 xcb_generic_error_t *error = (xcb_generic_error_t*)event;
95                 ELOG("X11 Error received! sequence 0x%x, error_code = %d\n",
96                      error->sequence, error->error_code);
97             }
98             free(event);
99             continue;
100         }
101
102         /* Strip off the highest bit (set if the event is generated) */
103         int type = (event->response_type & 0x7F);
104
105         handle_event(type, event);
106
107         free(event);
108     }
109 }
110
111
112 /*
113  * When using xmodmap to change the keyboard mapping, this event
114  * is only sent via XKB. Therefore, we need this special handler.
115  *
116  */
117 static void xkb_got_event(EV_P_ struct ev_io *w, int revents) {
118     DLOG("Handling XKB event\n");
119     XkbEvent ev;
120
121     /* When using xmodmap, every change (!) gets an own event.
122      * Therefore, we just read all events and only handle the
123      * mapping_notify once. */
124     bool mapping_changed = false;
125     while (XPending(xkbdpy)) {
126         XNextEvent(xkbdpy, (XEvent*)&ev);
127         /* While we should never receive a non-XKB event,
128          * better do sanity checking */
129         if (ev.type != xkb_event_base)
130             continue;
131
132         if (ev.any.xkb_type == XkbMapNotify) {
133             mapping_changed = true;
134             continue;
135         }
136
137         if (ev.any.xkb_type != XkbStateNotify) {
138             ELOG("Unknown XKB event received (type %d)\n", ev.any.xkb_type);
139             continue;
140         }
141
142         /* See The XKB Extension: Library Specification, section 14.1 */
143         /* We check if the current group (each group contains
144          * two levels) has been changed. Mode_switch activates
145          * group XkbGroup2Index */
146         if (xkb_current_group == ev.state.group)
147             continue;
148
149         xkb_current_group = ev.state.group;
150
151         if (ev.state.group == XkbGroup2Index) {
152             DLOG("Mode_switch enabled\n");
153             grab_all_keys(conn, true);
154         }
155
156         if (ev.state.group == XkbGroup1Index) {
157             DLOG("Mode_switch disabled\n");
158             ungrab_all_keys(conn);
159             grab_all_keys(conn, false);
160         }
161     }
162
163     if (!mapping_changed)
164         return;
165
166     DLOG("Keyboard mapping changed, updating keybindings\n");
167     xcb_key_symbols_free(keysyms);
168     keysyms = xcb_key_symbols_alloc(conn);
169
170     xcb_get_numlock_mask(conn);
171
172     ungrab_all_keys(conn);
173     DLOG("Re-grabbing...\n");
174     translate_keysyms();
175     grab_all_keys(conn, (xkb_current_group == XkbGroup2Index));
176     DLOG("Done\n");
177 }
178
179 /*
180  * Exit handler which destroys the main_loop. Will trigger cleanup handlers.
181  *
182  */
183 static void i3_exit() {
184     ev_loop_destroy(main_loop);
185 }
186
187 int main(int argc, char *argv[]) {
188     char *override_configpath = NULL;
189     bool autostart = true;
190     char *layout_path = NULL;
191     bool delete_layout_path = false;
192     bool only_check_config = false;
193     bool force_xinerama = false;
194     bool disable_signalhandler = false;
195     static struct option long_options[] = {
196         {"no-autostart", no_argument, 0, 'a'},
197         {"config", required_argument, 0, 'c'},
198         {"version", no_argument, 0, 'v'},
199         {"help", no_argument, 0, 'h'},
200         {"layout", required_argument, 0, 'L'},
201         {"restart", required_argument, 0, 0},
202         {"force-xinerama", no_argument, 0, 0},
203         {"disable-signalhandler", no_argument, 0, 0},
204         {"get-socketpath", no_argument, 0, 0},
205         {0, 0, 0, 0}
206     };
207     int option_index = 0, opt;
208
209     setlocale(LC_ALL, "");
210
211     /* Disable output buffering to make redirects in .xsession actually useful for debugging */
212     if (!isatty(fileno(stdout)))
213         setbuf(stdout, NULL);
214
215     init_logging();
216
217     start_argv = argv;
218
219     while ((opt = getopt_long(argc, argv, "c:CvaL:hld:V", long_options, &option_index)) != -1) {
220         switch (opt) {
221             case 'a':
222                 LOG("Autostart disabled using -a\n");
223                 autostart = false;
224                 break;
225             case 'L':
226                 FREE(layout_path);
227                 layout_path = sstrdup(optarg);
228                 delete_layout_path = false;
229                 break;
230             case 'c':
231                 FREE(override_configpath);
232                 override_configpath = sstrdup(optarg);
233                 break;
234             case 'C':
235                 LOG("Checking configuration file only (-C)\n");
236                 only_check_config = true;
237                 break;
238             case 'v':
239                 printf("i3 version " I3_VERSION " © 2009-2011 Michael Stapelberg and contributors\n");
240                 exit(EXIT_SUCCESS);
241             case 'V':
242                 set_verbosity(true);
243                 break;
244             case 'd':
245                 LOG("Enabling debug loglevel %s\n", optarg);
246                 add_loglevel(optarg);
247                 break;
248             case 'l':
249                 /* DEPRECATED, ignored for the next 3 versions (3.e, 3.f, 3.g) */
250                 break;
251             case 0:
252                 if (strcmp(long_options[option_index].name, "force-xinerama") == 0) {
253                     force_xinerama = true;
254                     ELOG("Using Xinerama instead of RandR. This option should be "
255                          "avoided at all cost because it does not refresh the list "
256                          "of screens, so you cannot configure displays at runtime. "
257                          "Please check if your driver really does not support RandR "
258                          "and disable this option as soon as you can.\n");
259                     break;
260                 } else if (strcmp(long_options[option_index].name, "disable-signalhandler") == 0) {
261                     disable_signalhandler = true;
262                     break;
263                 } else if (strcmp(long_options[option_index].name, "get-socketpath") == 0) {
264                     char *socket_path = socket_path_from_x11();
265                     if (socket_path) {
266                         printf("%s\n", socket_path);
267                         return 0;
268                     }
269
270                     return 1;
271                 } else if (strcmp(long_options[option_index].name, "restart") == 0) {
272                     FREE(layout_path);
273                     layout_path = sstrdup(optarg);
274                     delete_layout_path = true;
275                     break;
276                 }
277                 /* fall-through */
278             default:
279                 fprintf(stderr, "Usage: %s [-c configfile] [-d loglevel] [-a] [-v] [-V] [-C]\n", argv[0]);
280                 fprintf(stderr, "\n");
281                 fprintf(stderr, "\t-a          disable autostart ('exec' lines in config)\n");
282                 fprintf(stderr, "\t-c <file>   use the provided configfile instead\n");
283                 fprintf(stderr, "\t-C          validate configuration file and exit\n");
284                 fprintf(stderr, "\t-d <level>  enable debug output with the specified loglevel\n");
285                 fprintf(stderr, "\t-L <file>   path to the serialized layout during restarts\n");
286                 fprintf(stderr, "\t-v          display version and exit\n");
287                 fprintf(stderr, "\t-V          enable verbose mode\n");
288                 fprintf(stderr, "\n");
289                 fprintf(stderr, "\t--force-xinerama\n"
290                                 "\tUse Xinerama instead of RandR.\n"
291                                 "\tThis option should only be used if you are stuck with the\n"
292                                 "\tnvidia closed source driver which does not support RandR.\n");
293                 fprintf(stderr, "\n");
294                 fprintf(stderr, "\t--get-socketpath\n"
295                                 "\tRetrieve the i3 IPC socket path from X11, print it, then exit.\n");
296                 fprintf(stderr, "\n");
297                 fprintf(stderr, "If you pass plain text arguments, i3 will interpret them as a command\n"
298                                 "to send to a currently running i3 (like i3-msg). This allows you to\n"
299                                 "use nice and logical commands, such as:\n"
300                                 "\n"
301                                 "\ti3 border none\n"
302                                 "\ti3 floating toggle\n"
303                                 "\ti3 kill window\n"
304                                 "\n");
305                 exit(EXIT_FAILURE);
306         }
307     }
308
309     /* If the user passes more arguments, we act like i3-msg would: Just send
310      * the arguments as an IPC message to i3. This allows for nice semantic
311      * commands such as 'i3 border none'. */
312     if (optind < argc) {
313         /* We enable verbose mode so that the user knows what’s going on.
314          * This should make it easier to find mistakes when the user passes
315          * arguments by mistake. */
316         set_verbosity(true);
317
318         LOG("Additional arguments passed. Sending them as a command to i3.\n");
319         char *payload = NULL;
320         while (optind < argc) {
321             if (!payload) {
322                 payload = sstrdup(argv[optind]);
323             } else {
324                 char *both;
325                 if (asprintf(&both, "%s %s", payload, argv[optind]) == -1)
326                     err(EXIT_FAILURE, "asprintf");
327                 free(payload);
328                 payload = both;
329             }
330             optind++;
331         }
332         LOG("Command is: %s (%d bytes)\n", payload, strlen(payload));
333         char *socket_path = socket_path_from_x11();
334         if (!socket_path) {
335             ELOG("Could not get i3 IPC socket path\n");
336             return 1;
337         }
338
339         int sockfd = socket(AF_LOCAL, SOCK_STREAM, 0);
340         if (sockfd == -1)
341             err(EXIT_FAILURE, "Could not create socket");
342
343         struct sockaddr_un addr;
344         memset(&addr, 0, sizeof(struct sockaddr_un));
345         addr.sun_family = AF_LOCAL;
346         strncpy(addr.sun_path, socket_path, sizeof(addr.sun_path) - 1);
347         if (connect(sockfd, (const struct sockaddr*)&addr, sizeof(struct sockaddr_un)) < 0)
348             err(EXIT_FAILURE, "Could not connect to i3");
349
350         if (ipc_send_message(sockfd, strlen(payload), I3_IPC_MESSAGE_TYPE_COMMAND,
351                              (uint8_t*)payload) == -1)
352             err(EXIT_FAILURE, "IPC: write()");
353
354         uint32_t reply_length;
355         uint8_t *reply;
356         int ret;
357         if ((ret = ipc_recv_message(sockfd, I3_IPC_MESSAGE_TYPE_COMMAND,
358                                     &reply_length, &reply)) != 0) {
359             if (ret == -1)
360                 err(EXIT_FAILURE, "IPC: read()");
361             return 1;
362         }
363         printf("%.*s\n", reply_length, reply);
364         return 0;
365     }
366
367     LOG("i3 (tree) version " I3_VERSION " starting\n");
368
369     conn = xcb_connect(NULL, &conn_screen);
370     if (xcb_connection_has_error(conn))
371         errx(EXIT_FAILURE, "Cannot open display\n");
372
373     sndisplay = sn_xcb_display_new(conn, NULL, NULL);
374
375     /* Initialize the libev event loop. This needs to be done before loading
376      * the config file because the parser will install an ev_child watcher
377      * for the nagbar when config errors are found. */
378     main_loop = EV_DEFAULT;
379     if (main_loop == NULL)
380             die("Could not initialize libev. Bad LIBEV_FLAGS?\n");
381
382     root_screen = xcb_aux_get_screen(conn, conn_screen);
383     root = root_screen->root;
384     root_depth = root_screen->root_depth;
385     xcb_get_geometry_cookie_t gcookie = xcb_get_geometry(conn, root);
386     xcb_query_pointer_cookie_t pointercookie = xcb_query_pointer(conn, root);
387
388     load_configuration(conn, override_configpath, false);
389     if (only_check_config) {
390         LOG("Done checking configuration file. Exiting.\n");
391         exit(0);
392     }
393
394     if (config.ipc_socket_path == NULL) {
395         /* Fall back to a file name in /tmp/ based on the PID */
396         if ((config.ipc_socket_path = getenv("I3SOCK")) == NULL)
397             config.ipc_socket_path = get_process_filename("ipc-socket");
398         else
399             config.ipc_socket_path = sstrdup(config.ipc_socket_path);
400     }
401
402     uint32_t mask = XCB_CW_EVENT_MASK;
403     uint32_t values[] = { XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT |
404                           XCB_EVENT_MASK_STRUCTURE_NOTIFY |         /* when the user adds a screen (e.g. video
405                                                                            projector), the root window gets a
406                                                                            ConfigureNotify */
407                           XCB_EVENT_MASK_POINTER_MOTION |
408                           XCB_EVENT_MASK_PROPERTY_CHANGE |
409                           XCB_EVENT_MASK_ENTER_WINDOW };
410     xcb_void_cookie_t cookie;
411     cookie = xcb_change_window_attributes_checked(conn, root, mask, values);
412     check_error(conn, cookie, "Another window manager seems to be running");
413
414     xcb_get_geometry_reply_t *greply = xcb_get_geometry_reply(conn, gcookie, NULL);
415     if (greply == NULL) {
416         ELOG("Could not get geometry of the root window, exiting\n");
417         return 1;
418     }
419     DLOG("root geometry reply: (%d, %d) %d x %d\n", greply->x, greply->y, greply->width, greply->height);
420
421     /* Place requests for the atoms we need as soon as possible */
422     #define xmacro(atom) \
423         xcb_intern_atom_cookie_t atom ## _cookie = xcb_intern_atom(conn, 0, strlen(#atom), #atom);
424     #include "atoms.xmacro"
425     #undef xmacro
426
427     /* Initialize the Xlib connection */
428     xlibdpy = xkbdpy = XOpenDisplay(NULL);
429
430     /* Try to load the X cursors and initialize the XKB extension */
431     if (xlibdpy == NULL) {
432         ELOG("ERROR: XOpenDisplay() failed, disabling libXcursor/XKB support\n");
433         xcursor_supported = false;
434         xkb_supported = false;
435     } else if (fcntl(ConnectionNumber(xlibdpy), F_SETFD, FD_CLOEXEC) == -1) {
436         ELOG("Could not set FD_CLOEXEC on xkbdpy\n");
437         return 1;
438     } else {
439         xcursor_load_cursors();
440         /*init_xkb();*/
441     }
442
443     /* Set a cursor for the root window (otherwise the root window will show no
444        cursor until the first client is launched). */
445     if (xcursor_supported)
446         xcursor_set_root_cursor(XCURSOR_CURSOR_POINTER);
447     else xcb_set_root_cursor(XCURSOR_CURSOR_POINTER);
448
449     if (xkb_supported) {
450         int errBase,
451             major = XkbMajorVersion,
452             minor = XkbMinorVersion;
453
454         if (fcntl(ConnectionNumber(xkbdpy), F_SETFD, FD_CLOEXEC) == -1) {
455             fprintf(stderr, "Could not set FD_CLOEXEC on xkbdpy\n");
456             return 1;
457         }
458
459         int i1;
460         if (!XkbQueryExtension(xkbdpy,&i1,&xkb_event_base,&errBase,&major,&minor)) {
461             fprintf(stderr, "XKB not supported by X-server\n");
462             return 1;
463         }
464         /* end of ugliness */
465
466         if (!XkbSelectEvents(xkbdpy, XkbUseCoreKbd,
467                              XkbMapNotifyMask | XkbStateNotifyMask,
468                              XkbMapNotifyMask | XkbStateNotifyMask)) {
469             fprintf(stderr, "Could not set XKB event mask\n");
470             return 1;
471         }
472     }
473
474     /* Setup NetWM atoms */
475     #define xmacro(name) \
476         do { \
477             xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(conn, name ## _cookie, NULL); \
478             if (!reply) { \
479                 ELOG("Could not get atom " #name "\n"); \
480                 exit(-1); \
481             } \
482             A_ ## name = reply->atom; \
483             free(reply); \
484         } while (0);
485     #include "atoms.xmacro"
486     #undef xmacro
487
488     property_handlers_init();
489
490     /* Set up the atoms we support */
491     xcb_atom_t supported_atoms[] = {
492 #define xmacro(atom) A_ ## atom,
493 #include "atoms.xmacro"
494 #undef xmacro
495     };
496     xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_SUPPORTED, XCB_ATOM_ATOM, 32, 16, supported_atoms);
497     /* Set up the window manager’s name */
498     xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_SUPPORTING_WM_CHECK, XCB_ATOM_WINDOW, 32, 1, &root);
499     xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_WM_NAME, A_UTF8_STRING, 8, strlen("i3"), "i3");
500
501     keysyms = xcb_key_symbols_alloc(conn);
502
503     xcb_get_numlock_mask(conn);
504
505     translate_keysyms();
506     grab_all_keys(conn, false);
507
508     bool needs_tree_init = true;
509     if (layout_path) {
510         LOG("Trying to restore the layout from %s...", layout_path);
511         needs_tree_init = !tree_restore(layout_path, greply);
512         if (delete_layout_path)
513             unlink(layout_path);
514         free(layout_path);
515     }
516     if (needs_tree_init)
517         tree_init(greply);
518
519     free(greply);
520
521     /* Force Xinerama (for drivers which don't support RandR yet, esp. the
522      * nVidia binary graphics driver), when specified either in the config
523      * file or on command-line */
524     if (force_xinerama || config.force_xinerama) {
525         xinerama_init();
526     } else {
527         DLOG("Checking for XRandR...\n");
528         randr_init(&randr_base);
529     }
530
531     xcb_query_pointer_reply_t *pointerreply;
532     Output *output = NULL;
533     if (!(pointerreply = xcb_query_pointer_reply(conn, pointercookie, NULL))) {
534         ELOG("Could not query pointer position, using first screen\n");
535         output = get_first_output();
536     } else {
537         DLOG("Pointer at %d, %d\n", pointerreply->root_x, pointerreply->root_y);
538         output = get_output_containing(pointerreply->root_x, pointerreply->root_y);
539         if (!output) {
540             ELOG("ERROR: No screen at (%d, %d), starting on the first screen\n",
541                  pointerreply->root_x, pointerreply->root_y);
542             output = get_first_output();
543         }
544
545         con_focus(con_descend_focused(output_get_content(output->con)));
546     }
547
548     tree_render();
549
550     /* Create the UNIX domain socket for IPC */
551     int ipc_socket = ipc_create_socket(config.ipc_socket_path);
552     if (ipc_socket == -1) {
553         ELOG("Could not create the IPC socket, IPC disabled\n");
554     } else {
555         free(config.ipc_socket_path);
556         struct ev_io *ipc_io = scalloc(sizeof(struct ev_io));
557         ev_io_init(ipc_io, ipc_new_client, ipc_socket, EV_READ);
558         ev_io_start(main_loop, ipc_io);
559     }
560
561     /* Also handle the UNIX domain sockets passed via socket activation */
562     int fds = sd_listen_fds(1);
563     if (fds < 0)
564         ELOG("socket activation: Error in sd_listen_fds\n");
565     else if (fds == 0)
566         DLOG("socket activation: no sockets passed\n");
567     else {
568         for (int fd = SD_LISTEN_FDS_START; fd < (SD_LISTEN_FDS_START + fds); fd++) {
569             DLOG("socket activation: also listening on fd %d\n", fd);
570             struct ev_io *ipc_io = scalloc(sizeof(struct ev_io));
571             ev_io_init(ipc_io, ipc_new_client, fd, EV_READ);
572             ev_io_start(main_loop, ipc_io);
573         }
574     }
575
576     /* Set up i3 specific atoms like I3_SOCKET_PATH and I3_CONFIG_PATH */
577     x_set_i3_atoms();
578
579     struct ev_io *xcb_watcher = scalloc(sizeof(struct ev_io));
580     struct ev_io *xkb = scalloc(sizeof(struct ev_io));
581     struct ev_check *xcb_check = scalloc(sizeof(struct ev_check));
582     struct ev_prepare *xcb_prepare = scalloc(sizeof(struct ev_prepare));
583
584     ev_io_init(xcb_watcher, xcb_got_event, xcb_get_file_descriptor(conn), EV_READ);
585     ev_io_start(main_loop, xcb_watcher);
586
587
588     if (xkb_supported) {
589         ev_io_init(xkb, xkb_got_event, ConnectionNumber(xkbdpy), EV_READ);
590         ev_io_start(main_loop, xkb);
591
592         /* Flush the buffer so that libev can properly get new events */
593         XFlush(xkbdpy);
594     }
595
596     ev_check_init(xcb_check, xcb_check_cb);
597     ev_check_start(main_loop, xcb_check);
598
599     ev_prepare_init(xcb_prepare, xcb_prepare_cb);
600     ev_prepare_start(main_loop, xcb_prepare);
601
602     xcb_flush(conn);
603
604     manage_existing_windows(root);
605
606     if (!disable_signalhandler)
607         setup_signal_handler();
608
609     /* Ignore SIGPIPE to survive errors when an IPC client disconnects
610      * while we are sending him a message */
611     signal(SIGPIPE, SIG_IGN);
612
613     /* Autostarting exec-lines */
614     if (autostart) {
615         struct Autostart *exec;
616         TAILQ_FOREACH(exec, &autostarts, autostarts) {
617             LOG("auto-starting %s\n", exec->command);
618             start_application(exec->command);
619         }
620     }
621
622     /* Autostarting exec_always-lines */
623     struct Autostart *exec_always;
624     TAILQ_FOREACH(exec_always, &autostarts_always, autostarts_always) {
625         LOG("auto-starting (always!) %s\n", exec_always->command);
626         start_application(exec_always->command);
627     }
628
629     /* Make sure to destroy the event loop to invoke the cleeanup callbacks
630      * when calling exit() */
631     atexit(i3_exit);
632
633     ev_loop(main_loop, 0);
634 }