]> git.sur5r.net Git - i3/i3/blob - src/main.c
Create different IDs for each bar (+test)
[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 /* We need ev >= 4 for the following code. Since it is not *that* important (it
185  * only makes sure that there are no i3-nagbar instances left behind) we still
186  * support old systems with libev 3. */
187 #if EV_VERSION_MAJOR >= 4
188     ev_loop_destroy(main_loop);
189 #endif
190 }
191
192 int main(int argc, char *argv[]) {
193     char *override_configpath = NULL;
194     bool autostart = true;
195     char *layout_path = NULL;
196     bool delete_layout_path = false;
197     bool only_check_config = false;
198     bool force_xinerama = false;
199     bool disable_signalhandler = false;
200     static struct option long_options[] = {
201         {"no-autostart", no_argument, 0, 'a'},
202         {"config", required_argument, 0, 'c'},
203         {"version", no_argument, 0, 'v'},
204         {"help", no_argument, 0, 'h'},
205         {"layout", required_argument, 0, 'L'},
206         {"restart", required_argument, 0, 0},
207         {"force-xinerama", no_argument, 0, 0},
208         {"disable-signalhandler", no_argument, 0, 0},
209         {"get-socketpath", no_argument, 0, 0},
210         {0, 0, 0, 0}
211     };
212     int option_index = 0, opt;
213
214     setlocale(LC_ALL, "");
215
216     /* Disable output buffering to make redirects in .xsession actually useful for debugging */
217     if (!isatty(fileno(stdout)))
218         setbuf(stdout, NULL);
219
220     srand(time(NULL));
221
222     init_logging();
223
224     start_argv = argv;
225
226     while ((opt = getopt_long(argc, argv, "c:CvaL:hld:V", long_options, &option_index)) != -1) {
227         switch (opt) {
228             case 'a':
229                 LOG("Autostart disabled using -a\n");
230                 autostart = false;
231                 break;
232             case 'L':
233                 FREE(layout_path);
234                 layout_path = sstrdup(optarg);
235                 delete_layout_path = false;
236                 break;
237             case 'c':
238                 FREE(override_configpath);
239                 override_configpath = sstrdup(optarg);
240                 break;
241             case 'C':
242                 LOG("Checking configuration file only (-C)\n");
243                 only_check_config = true;
244                 break;
245             case 'v':
246                 printf("i3 version " I3_VERSION " © 2009-2011 Michael Stapelberg and contributors\n");
247                 exit(EXIT_SUCCESS);
248             case 'V':
249                 set_verbosity(true);
250                 break;
251             case 'd':
252                 LOG("Enabling debug loglevel %s\n", optarg);
253                 add_loglevel(optarg);
254                 break;
255             case 'l':
256                 /* DEPRECATED, ignored for the next 3 versions (3.e, 3.f, 3.g) */
257                 break;
258             case 0:
259                 if (strcmp(long_options[option_index].name, "force-xinerama") == 0) {
260                     force_xinerama = true;
261                     ELOG("Using Xinerama instead of RandR. This option should be "
262                          "avoided at all cost because it does not refresh the list "
263                          "of screens, so you cannot configure displays at runtime. "
264                          "Please check if your driver really does not support RandR "
265                          "and disable this option as soon as you can.\n");
266                     break;
267                 } else if (strcmp(long_options[option_index].name, "disable-signalhandler") == 0) {
268                     disable_signalhandler = true;
269                     break;
270                 } else if (strcmp(long_options[option_index].name, "get-socketpath") == 0) {
271                     char *socket_path = socket_path_from_x11();
272                     if (socket_path) {
273                         printf("%s\n", socket_path);
274                         return 0;
275                     }
276
277                     return 1;
278                 } else if (strcmp(long_options[option_index].name, "restart") == 0) {
279                     FREE(layout_path);
280                     layout_path = sstrdup(optarg);
281                     delete_layout_path = true;
282                     break;
283                 }
284                 /* fall-through */
285             default:
286                 fprintf(stderr, "Usage: %s [-c configfile] [-d loglevel] [-a] [-v] [-V] [-C]\n", argv[0]);
287                 fprintf(stderr, "\n");
288                 fprintf(stderr, "\t-a          disable autostart ('exec' lines in config)\n");
289                 fprintf(stderr, "\t-c <file>   use the provided configfile instead\n");
290                 fprintf(stderr, "\t-C          validate configuration file and exit\n");
291                 fprintf(stderr, "\t-d <level>  enable debug output with the specified loglevel\n");
292                 fprintf(stderr, "\t-L <file>   path to the serialized layout during restarts\n");
293                 fprintf(stderr, "\t-v          display version and exit\n");
294                 fprintf(stderr, "\t-V          enable verbose mode\n");
295                 fprintf(stderr, "\n");
296                 fprintf(stderr, "\t--force-xinerama\n"
297                                 "\tUse Xinerama instead of RandR.\n"
298                                 "\tThis option should only be used if you are stuck with the\n"
299                                 "\tnvidia closed source driver which does not support RandR.\n");
300                 fprintf(stderr, "\n");
301                 fprintf(stderr, "\t--get-socketpath\n"
302                                 "\tRetrieve the i3 IPC socket path from X11, print it, then exit.\n");
303                 fprintf(stderr, "\n");
304                 fprintf(stderr, "If you pass plain text arguments, i3 will interpret them as a command\n"
305                                 "to send to a currently running i3 (like i3-msg). This allows you to\n"
306                                 "use nice and logical commands, such as:\n"
307                                 "\n"
308                                 "\ti3 border none\n"
309                                 "\ti3 floating toggle\n"
310                                 "\ti3 kill window\n"
311                                 "\n");
312                 exit(EXIT_FAILURE);
313         }
314     }
315
316     /* If the user passes more arguments, we act like i3-msg would: Just send
317      * the arguments as an IPC message to i3. This allows for nice semantic
318      * commands such as 'i3 border none'. */
319     if (optind < argc) {
320         /* We enable verbose mode so that the user knows what’s going on.
321          * This should make it easier to find mistakes when the user passes
322          * arguments by mistake. */
323         set_verbosity(true);
324
325         LOG("Additional arguments passed. Sending them as a command to i3.\n");
326         char *payload = NULL;
327         while (optind < argc) {
328             if (!payload) {
329                 payload = sstrdup(argv[optind]);
330             } else {
331                 char *both;
332                 if (asprintf(&both, "%s %s", payload, argv[optind]) == -1)
333                     err(EXIT_FAILURE, "asprintf");
334                 free(payload);
335                 payload = both;
336             }
337             optind++;
338         }
339         LOG("Command is: %s (%d bytes)\n", payload, strlen(payload));
340         char *socket_path = socket_path_from_x11();
341         if (!socket_path) {
342             ELOG("Could not get i3 IPC socket path\n");
343             return 1;
344         }
345
346         int sockfd = socket(AF_LOCAL, SOCK_STREAM, 0);
347         if (sockfd == -1)
348             err(EXIT_FAILURE, "Could not create socket");
349
350         struct sockaddr_un addr;
351         memset(&addr, 0, sizeof(struct sockaddr_un));
352         addr.sun_family = AF_LOCAL;
353         strncpy(addr.sun_path, socket_path, sizeof(addr.sun_path) - 1);
354         if (connect(sockfd, (const struct sockaddr*)&addr, sizeof(struct sockaddr_un)) < 0)
355             err(EXIT_FAILURE, "Could not connect to i3");
356
357         if (ipc_send_message(sockfd, strlen(payload), I3_IPC_MESSAGE_TYPE_COMMAND,
358                              (uint8_t*)payload) == -1)
359             err(EXIT_FAILURE, "IPC: write()");
360
361         uint32_t reply_length;
362         uint8_t *reply;
363         int ret;
364         if ((ret = ipc_recv_message(sockfd, I3_IPC_MESSAGE_TYPE_COMMAND,
365                                     &reply_length, &reply)) != 0) {
366             if (ret == -1)
367                 err(EXIT_FAILURE, "IPC: read()");
368             return 1;
369         }
370         printf("%.*s\n", reply_length, reply);
371         return 0;
372     }
373
374     LOG("i3 (tree) version " I3_VERSION " starting\n");
375
376     conn = xcb_connect(NULL, &conn_screen);
377     if (xcb_connection_has_error(conn))
378         errx(EXIT_FAILURE, "Cannot open display\n");
379
380     sndisplay = sn_xcb_display_new(conn, NULL, NULL);
381
382     /* Initialize the libev event loop. This needs to be done before loading
383      * the config file because the parser will install an ev_child watcher
384      * for the nagbar when config errors are found. */
385     main_loop = EV_DEFAULT;
386     if (main_loop == NULL)
387             die("Could not initialize libev. Bad LIBEV_FLAGS?\n");
388
389     root_screen = xcb_aux_get_screen(conn, conn_screen);
390     root = root_screen->root;
391     root_depth = root_screen->root_depth;
392     xcb_get_geometry_cookie_t gcookie = xcb_get_geometry(conn, root);
393     xcb_query_pointer_cookie_t pointercookie = xcb_query_pointer(conn, root);
394
395     load_configuration(conn, override_configpath, false);
396     if (only_check_config) {
397         LOG("Done checking configuration file. Exiting.\n");
398         exit(0);
399     }
400
401     if (config.ipc_socket_path == NULL) {
402         /* Fall back to a file name in /tmp/ based on the PID */
403         if ((config.ipc_socket_path = getenv("I3SOCK")) == NULL)
404             config.ipc_socket_path = get_process_filename("ipc-socket");
405         else
406             config.ipc_socket_path = sstrdup(config.ipc_socket_path);
407     }
408
409     uint32_t mask = XCB_CW_EVENT_MASK;
410     uint32_t values[] = { XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT |
411                           XCB_EVENT_MASK_STRUCTURE_NOTIFY |         /* when the user adds a screen (e.g. video
412                                                                            projector), the root window gets a
413                                                                            ConfigureNotify */
414                           XCB_EVENT_MASK_POINTER_MOTION |
415                           XCB_EVENT_MASK_PROPERTY_CHANGE |
416                           XCB_EVENT_MASK_ENTER_WINDOW };
417     xcb_void_cookie_t cookie;
418     cookie = xcb_change_window_attributes_checked(conn, root, mask, values);
419     check_error(conn, cookie, "Another window manager seems to be running");
420
421     xcb_get_geometry_reply_t *greply = xcb_get_geometry_reply(conn, gcookie, NULL);
422     if (greply == NULL) {
423         ELOG("Could not get geometry of the root window, exiting\n");
424         return 1;
425     }
426     DLOG("root geometry reply: (%d, %d) %d x %d\n", greply->x, greply->y, greply->width, greply->height);
427
428     /* Place requests for the atoms we need as soon as possible */
429     #define xmacro(atom) \
430         xcb_intern_atom_cookie_t atom ## _cookie = xcb_intern_atom(conn, 0, strlen(#atom), #atom);
431     #include "atoms.xmacro"
432     #undef xmacro
433
434     /* Initialize the Xlib connection */
435     xlibdpy = xkbdpy = XOpenDisplay(NULL);
436
437     /* Try to load the X cursors and initialize the XKB extension */
438     if (xlibdpy == NULL) {
439         ELOG("ERROR: XOpenDisplay() failed, disabling libXcursor/XKB support\n");
440         xcursor_supported = false;
441         xkb_supported = false;
442     } else if (fcntl(ConnectionNumber(xlibdpy), F_SETFD, FD_CLOEXEC) == -1) {
443         ELOG("Could not set FD_CLOEXEC on xkbdpy\n");
444         return 1;
445     } else {
446         xcursor_load_cursors();
447         /*init_xkb();*/
448     }
449
450     /* Set a cursor for the root window (otherwise the root window will show no
451        cursor until the first client is launched). */
452     if (xcursor_supported)
453         xcursor_set_root_cursor(XCURSOR_CURSOR_POINTER);
454     else xcb_set_root_cursor(XCURSOR_CURSOR_POINTER);
455
456     if (xkb_supported) {
457         int errBase,
458             major = XkbMajorVersion,
459             minor = XkbMinorVersion;
460
461         if (fcntl(ConnectionNumber(xkbdpy), F_SETFD, FD_CLOEXEC) == -1) {
462             fprintf(stderr, "Could not set FD_CLOEXEC on xkbdpy\n");
463             return 1;
464         }
465
466         int i1;
467         if (!XkbQueryExtension(xkbdpy,&i1,&xkb_event_base,&errBase,&major,&minor)) {
468             fprintf(stderr, "XKB not supported by X-server\n");
469             return 1;
470         }
471         /* end of ugliness */
472
473         if (!XkbSelectEvents(xkbdpy, XkbUseCoreKbd,
474                              XkbMapNotifyMask | XkbStateNotifyMask,
475                              XkbMapNotifyMask | XkbStateNotifyMask)) {
476             fprintf(stderr, "Could not set XKB event mask\n");
477             return 1;
478         }
479     }
480
481     /* Setup NetWM atoms */
482     #define xmacro(name) \
483         do { \
484             xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(conn, name ## _cookie, NULL); \
485             if (!reply) { \
486                 ELOG("Could not get atom " #name "\n"); \
487                 exit(-1); \
488             } \
489             A_ ## name = reply->atom; \
490             free(reply); \
491         } while (0);
492     #include "atoms.xmacro"
493     #undef xmacro
494
495     property_handlers_init();
496
497     /* Set up the atoms we support */
498     xcb_atom_t supported_atoms[] = {
499 #define xmacro(atom) A_ ## atom,
500 #include "atoms.xmacro"
501 #undef xmacro
502     };
503     xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_SUPPORTED, XCB_ATOM_ATOM, 32, 16, supported_atoms);
504     /* Set up the window manager’s name */
505     xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_SUPPORTING_WM_CHECK, XCB_ATOM_WINDOW, 32, 1, &root);
506     xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_WM_NAME, A_UTF8_STRING, 8, strlen("i3"), "i3");
507
508     keysyms = xcb_key_symbols_alloc(conn);
509
510     xcb_get_numlock_mask(conn);
511
512     translate_keysyms();
513     grab_all_keys(conn, false);
514
515     bool needs_tree_init = true;
516     if (layout_path) {
517         LOG("Trying to restore the layout from %s...", layout_path);
518         needs_tree_init = !tree_restore(layout_path, greply);
519         if (delete_layout_path)
520             unlink(layout_path);
521         free(layout_path);
522     }
523     if (needs_tree_init)
524         tree_init(greply);
525
526     free(greply);
527
528     /* Force Xinerama (for drivers which don't support RandR yet, esp. the
529      * nVidia binary graphics driver), when specified either in the config
530      * file or on command-line */
531     if (force_xinerama || config.force_xinerama) {
532         xinerama_init();
533     } else {
534         DLOG("Checking for XRandR...\n");
535         randr_init(&randr_base);
536     }
537
538     xcb_query_pointer_reply_t *pointerreply;
539     Output *output = NULL;
540     if (!(pointerreply = xcb_query_pointer_reply(conn, pointercookie, NULL))) {
541         ELOG("Could not query pointer position, using first screen\n");
542         output = get_first_output();
543     } else {
544         DLOG("Pointer at %d, %d\n", pointerreply->root_x, pointerreply->root_y);
545         output = get_output_containing(pointerreply->root_x, pointerreply->root_y);
546         if (!output) {
547             ELOG("ERROR: No screen at (%d, %d), starting on the first screen\n",
548                  pointerreply->root_x, pointerreply->root_y);
549             output = get_first_output();
550         }
551
552         con_focus(con_descend_focused(output_get_content(output->con)));
553     }
554
555     tree_render();
556
557     /* Create the UNIX domain socket for IPC */
558     int ipc_socket = ipc_create_socket(config.ipc_socket_path);
559     if (ipc_socket == -1) {
560         ELOG("Could not create the IPC socket, IPC disabled\n");
561     } else {
562         free(config.ipc_socket_path);
563         struct ev_io *ipc_io = scalloc(sizeof(struct ev_io));
564         ev_io_init(ipc_io, ipc_new_client, ipc_socket, EV_READ);
565         ev_io_start(main_loop, ipc_io);
566     }
567
568     /* Also handle the UNIX domain sockets passed via socket activation */
569     int fds = sd_listen_fds(1);
570     if (fds < 0)
571         ELOG("socket activation: Error in sd_listen_fds\n");
572     else if (fds == 0)
573         DLOG("socket activation: no sockets passed\n");
574     else {
575         for (int fd = SD_LISTEN_FDS_START; fd < (SD_LISTEN_FDS_START + fds); fd++) {
576             DLOG("socket activation: also listening on fd %d\n", fd);
577             struct ev_io *ipc_io = scalloc(sizeof(struct ev_io));
578             ev_io_init(ipc_io, ipc_new_client, fd, EV_READ);
579             ev_io_start(main_loop, ipc_io);
580         }
581     }
582
583     /* Set up i3 specific atoms like I3_SOCKET_PATH and I3_CONFIG_PATH */
584     x_set_i3_atoms();
585
586     struct ev_io *xcb_watcher = scalloc(sizeof(struct ev_io));
587     struct ev_io *xkb = scalloc(sizeof(struct ev_io));
588     struct ev_check *xcb_check = scalloc(sizeof(struct ev_check));
589     struct ev_prepare *xcb_prepare = scalloc(sizeof(struct ev_prepare));
590
591     ev_io_init(xcb_watcher, xcb_got_event, xcb_get_file_descriptor(conn), EV_READ);
592     ev_io_start(main_loop, xcb_watcher);
593
594
595     if (xkb_supported) {
596         ev_io_init(xkb, xkb_got_event, ConnectionNumber(xkbdpy), EV_READ);
597         ev_io_start(main_loop, xkb);
598
599         /* Flush the buffer so that libev can properly get new events */
600         XFlush(xkbdpy);
601     }
602
603     ev_check_init(xcb_check, xcb_check_cb);
604     ev_check_start(main_loop, xcb_check);
605
606     ev_prepare_init(xcb_prepare, xcb_prepare_cb);
607     ev_prepare_start(main_loop, xcb_prepare);
608
609     xcb_flush(conn);
610
611     manage_existing_windows(root);
612
613     if (!disable_signalhandler)
614         setup_signal_handler();
615
616     /* Ignore SIGPIPE to survive errors when an IPC client disconnects
617      * while we are sending him a message */
618     signal(SIGPIPE, SIG_IGN);
619
620     /* Autostarting exec-lines */
621     if (autostart) {
622         struct Autostart *exec;
623         TAILQ_FOREACH(exec, &autostarts, autostarts) {
624             LOG("auto-starting %s\n", exec->command);
625             start_application(exec->command);
626         }
627     }
628
629     /* Autostarting exec_always-lines */
630     struct Autostart *exec_always;
631     TAILQ_FOREACH(exec_always, &autostarts_always, autostarts_always) {
632         LOG("auto-starting (always!) %s\n", exec_always->command);
633         start_application(exec_always->command);
634     }
635
636     /* Make sure to destroy the event loop to invoke the cleeanup callbacks
637      * when calling exit() */
638     atexit(i3_exit);
639
640     ev_loop(main_loop, 0);
641 }