]> git.sur5r.net Git - i3/i3/blobdiff - i3bar/src/main.c
Update changelog and copyright, bump version and more
[i3/i3] / i3bar / src / main.c
index 1c3236432e6820d8e104eb4e31b3762a36b536c2..d3107bfb071b5c47f198d3acf63a1d6ece4d8195 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * i3bar - an xcb-based status- and ws-bar for i3
  *
- * © 2010 Axel Wagner and contributors
+ * © 2010-2011 Axel Wagner and contributors
  *
  * See file LICNSE for license information
  *
@@ -81,11 +81,11 @@ static void free_colors(struct xcb_color_strings_t *colors) {
 }
 
 void print_usage(char *elf_name) {
-    printf("Usage: %s [-s sock_path] [-c command] [-m|-d [pos]] [-f font] [-V] [-h]\n", elf_name);
+    printf("Usage: %s [-s sock_path] [-c command] [-m|-d[pos]] [-f font] [-V] [-h]\n", elf_name);
     printf("-s <sock_path>\tConnect to i3 via <sock_path>\n");
     printf("-c <command>\tExecute <command> to get stdin\n");
     printf("-m\t\tHide the bars, when mod4 is not pressed.\n");
-    printf("-d [<pos>]\tEnable dockmode. <pos> is \"top\" or \"bottom\". Default is bottom\n");
+    printf("-d[<pos>]\tEnable dockmode. <pos> is \"top\" or \"bottom\". Default is bottom\n");
     printf("\t\tIf -c is specified, the childprocess is sent a SIGSTOP on hiding,\n");
     printf("\t\tand a SIGCONT on unhiding of the bars\n");
     printf("-f <font>\tUse X-Core-Font <font> for display\n");
@@ -151,7 +151,7 @@ int main(int argc, char **argv) {
         { NULL,                   0,                 0, 0}
     };
 
-    while ((opt = getopt_long(argc, argv, "s:c:d:mf:whvVA:B:C:D:E:F:G:H:I:J:", long_opt, &option_index)) != -1) {
+    while ((opt = getopt_long(argc, argv, "s:c:d::mf:whvVA:B:C:D:E:F:G:H:I:J:", long_opt, &option_index)) != -1) {
         switch (opt) {
             case 's':
                 socket_path = expand_path(optarg);
@@ -184,7 +184,7 @@ int main(int argc, char **argv) {
                 config.disable_ws = 1;
                 break;
             case 'v':
-                printf("i3bar version " I3BAR_VERSION " © 2010 Axel Wagner and contributors\n");
+                printf("i3bar version " I3BAR_VERSION " © 2010-2011 Axel Wagner and contributors\n");
                 exit(EXIT_SUCCESS);
                 break;
             case 'V':
@@ -281,15 +281,22 @@ int main(int argc, char **argv) {
     /* We listen to SIGTERM/QUIT/INT and try to exit cleanly, by stopping the main-loop.
      * We only need those watchers on the stack, so putting them on the stack saves us
      * some calls to free() */
-    ev_signal sig_term, sig_int, sig_hup;
+    ev_signal *sig_term = malloc(sizeof(ev_signal));
+    ev_signal *sig_int = malloc(sizeof(ev_signal));
+    ev_signal *sig_hup = malloc(sizeof(ev_signal));
 
-    ev_signal_init(&sig_term, &sig_cb, SIGTERM);
-    ev_signal_init(&sig_int, &sig_cb, SIGINT);
-    ev_signal_init(&sig_hup, &sig_cb, SIGHUP);
+    if (sig_term == NULL || sig_int == NULL || sig_hup == NULL) {
+        ELOG("malloc() failed: %s\n", strerror(errno));
+        exit(EXIT_FAILURE);
+    }
+
+    ev_signal_init(sig_term, &sig_cb, SIGTERM);
+    ev_signal_init(sig_int, &sig_cb, SIGINT);
+    ev_signal_init(sig_hup, &sig_cb, SIGHUP);
 
-    ev_signal_start(main_loop, &sig_term);
-    ev_signal_start(main_loop, &sig_int);
-    ev_signal_start(main_loop, &sig_hup);
+    ev_signal_start(main_loop, sig_term);
+    ev_signal_start(main_loop, sig_int);
+    ev_signal_start(main_loop, sig_hup);
 
     /* From here on everything should run smooth for itself, just start listening for
      * events. We stop simply stop the event-loop, when we are finished */