]> git.sur5r.net Git - i3/i3/blobdiff - i3bar/src/main.c
i3bar: free output data structures
[i3/i3] / i3bar / src / main.c
index ee3d81b974e23923ec2dcacfa2dce47b28708887..069803d4f944289afac72323bf15acd8d24fae03 100644 (file)
@@ -2,9 +2,11 @@
  * 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 "common.h"
+
 #include <stdio.h>
 #include <i3/ipc.h>
 #include <string.h>
@@ -15,8 +17,6 @@
 #include <getopt.h>
 #include <glob.h>
 
-#include "common.h"
-
 /*
  * Having verboselog(), errorlog() and debuglog() is necessary when using libi3.
  *
@@ -60,7 +60,7 @@ void print_usage(char *elf_name) {
     printf("\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("-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"
@@ -71,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
  *
  */
@@ -93,6 +93,9 @@ int main(int argc, char **argv) {
     int opt;
     int option_index = 0;
     char *socket_path = getenv("I3SOCK");
+    if (socket_path != NULL) {
+        socket_path = sstrdup(socket_path);
+    }
     char *i3_default_sock_path = "/tmp/i3-ipc.sock";
 
     /* Initialize the standard config to use 0 as default */
@@ -111,7 +114,7 @@ int main(int argc, char **argv) {
                 socket_path = expand_path(optarg);
                 break;
             case 'v':
-                printf("i3bar version " I3_VERSION " © 2010-2014 Axel Wagner and contributors\n");
+                printf("i3bar version " I3_VERSION " © 2010 Axel Wagner and contributors\n");
                 exit(EXIT_SUCCESS);
                 break;
             case 'b':
@@ -137,20 +140,25 @@ int main(int argc, char **argv) {
 
     if (socket_path == NULL) {
         socket_path = atom_sock_path;
+    } else {
+        free(atom_sock_path);
     }
 
     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);
     }
 
+    init_dpi();
+
     init_outputs();
     if (init_connection(socket_path)) {
         /* Request the bar configuration. When it arrives, we fill the config array. */
         i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_BAR_CONFIG, config.bar_id);
     }
+    free(socket_path);
 
-    /* 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));
@@ -166,7 +174,7 @@ 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();
@@ -174,7 +182,5 @@ int main(int argc, char **argv) {
     clean_xcb();
     ev_default_destroy();
 
-    free_workspaces();
-
     return 0;
 }