]> git.sur5r.net Git - i3/i3/blobdiff - i3bar/src/main.c
Merge branch 'next' into master
[i3/i3] / i3bar / src / main.c
index ea6056470c5f05381fc4c1e9efffddb1e3abbb7b..32425319ed3c5afc59a9516d1f434a208ad59fbf 100644 (file)
@@ -2,7 +2,7 @@
  * vim:ts=4:sw=4:expandtab
  *
  * i3bar - an xcb-based status- and ws-bar for i3
- * © 2010-2012 Axel Wagner and contributors (see also: LICENSE)
+ * © 2010 Axel Wagner and contributors (see also: LICENSE)
  *
  */
 #include <stdio.h>
@@ -18,7 +18,7 @@
 #include "common.h"
 
 /*
- * Having verboselog() and errorlog() is necessary when using libi3.
+ * Having verboselog(), errorlog() and debuglog() is necessary when using libi3.
  *
  */
 void verboselog(char *fmt, ...) {
@@ -37,6 +37,9 @@ void errorlog(char *fmt, ...) {
     va_end(args);
 }
 
+void debuglog(char *fmt, ...) {
+}
+
 /*
  * Glob path, i.e. expand ~
  *
@@ -53,12 +56,12 @@ char *expand_path(char *path) {
 }
 
 void print_usage(char *elf_name) {
-    printf("Usage: %s [-b bar_id] [-s sock_path] [-h] [-v]\n", elf_name);
+    printf("Usage: %s -b bar_id [-s sock_path] [-h] [-v]\n", elf_name);
     printf("\n");
-    printf("--bar_id <bar_id>\tBar ID for which to get the configuration\n");
-    printf("-s <sock_path>\tConnect to i3 via <sock_path>\n");
-    printf("-h\t\tDisplay this help-message and exit\n");
-    printf("-v\t\tDisplay version number and exit\n");
+    printf("-b, --bar_id  <bar_id>\tBar ID for which to get the configuration\n");
+    printf("-s, --socket  <sock_path>\tConnect to i3 via <sock_path>\n");
+    printf("-h, --help    Display this help message and exit\n");
+    printf("-v, --version Display version number and exit\n");
     printf("\n");
     printf(" PLEASE NOTE that i3bar will be automatically started by i3\n"
            " as soon as there is a 'bar' configuration block in your\n"
@@ -68,7 +71,7 @@ void print_usage(char *elf_name) {
 
 /*
  * We watch various signals, that are there to make our application stop.
- * If we get one of those, we ev_unloop() and invoke the cleanup-routines
+ * If we get one of those, we ev_unloop() and invoke the cleanup routines
  * in main() with that
  *
  */
@@ -96,27 +99,23 @@ int main(int argc, char **argv) {
     memset(&config, '\0', sizeof(config_t));
 
     static struct option long_opt[] = {
-        { "socket",               required_argument, 0, 's' },
-        { "bar_id",               required_argument, 0, 0 },
-        { "help",                 no_argument,       0, 'h' },
-        { "version",              no_argument,       0, 'v' },
-        { NULL,                   0,                 0, 0}
-    };
-
-    while ((opt = getopt_long(argc, argv, "s:hv", long_opt, &option_index)) != -1) {
+        {"socket", required_argument, 0, 's'},
+        {"bar_id", required_argument, 0, 'b'},
+        {"help", no_argument, 0, 'h'},
+        {"version", no_argument, 0, 'v'},
+        {NULL, 0, 0, 0}};
+
+    while ((opt = getopt_long(argc, argv, "b:s:hv", long_opt, &option_index)) != -1) {
         switch (opt) {
             case 's':
                 socket_path = expand_path(optarg);
                 break;
             case 'v':
-                printf("i3bar version " I3_VERSION " © 2010-2011 Axel Wagner and contributors\n");
+                printf("i3bar version " I3_VERSION " © 2010 Axel Wagner and contributors\n");
                 exit(EXIT_SUCCESS);
                 break;
-            case 0:
-                if (!strcmp(long_opt[option_index].name, "bar_id")) {
-                    FREE(config.bar_id);
-                    config.bar_id = sstrdup(optarg);
-                }
+            case 'b':
+                config.bar_id = sstrdup(optarg);
                 break;
             default:
                 print_usage(argv[0]);
@@ -141,7 +140,7 @@ int main(int argc, char **argv) {
     }
 
     if (socket_path == NULL) {
-        ELOG("No Socket Path Specified, default to %s\n", i3_default_sock_path);
+        ELOG("No socket path specified, default to %s\n", i3_default_sock_path);
         socket_path = expand_path(i3_default_sock_path);
     }
 
@@ -151,7 +150,7 @@ int main(int argc, char **argv) {
         i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_BAR_CONFIG, config.bar_id);
     }
 
-    /* We listen to SIGTERM/QUIT/INT and try to exit cleanly, by stopping the main-loop.
+    /* 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 = smalloc(sizeof(ev_signal));
@@ -167,13 +166,11 @@ int main(int argc, char **argv) {
     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 */
+     * events. We stop simply stop the event loop, when we are finished */
     ev_loop(main_loop, 0);
 
     kill_child();
 
-    FREE(statusline_buffer);
-
     clean_xcb();
     ev_default_destroy();