i3 - improved tiling WM


i3bar: fix usage description, make -b happen

Patch status: merged

Patch by Simon Elsbrock

To apply this patch, use:
curl http://cr.i3wm.org/patch/117/raw.patch | git am

b/i3bar/src/main.c

13
@@ -53,12 +53,12 @@ char *expand_path(char *path) {
14
 }
15
 
16
 void print_usage(char *elf_name) {
17
-    printf("Usage: %s [-b bar_id] [-s sock_path] [-h] [-v]\n", elf_name);
18
+    printf("Usage: %s -b bar_id [-s sock_path] [-h] [-v]\n", elf_name);
19
     printf("\n");
20
-    printf("--bar_id <bar_id>\tBar ID for which to get the configuration\n");
21
-    printf("-s <sock_path>\tConnect to i3 via <sock_path>\n");
22
-    printf("-h\t\tDisplay this help-message and exit\n");
23
-    printf("-v\t\tDisplay version number and exit\n");
24
+    printf("-b, --bar_id  <bar_id>\tBar ID for which to get the configuration\n");
25
+    printf("-s, --socket  <sock_path>\tConnect to i3 via <sock_path>\n");
26
+    printf("-h, --help    Display this help-message and exit\n");
27
+    printf("-v, --version Display version number and exit\n");
28
     printf("\n");
29
     printf(" PLEASE NOTE that i3bar will be automatically started by i3\n"
30
            " as soon as there is a 'bar' configuration block in your\n"
31
@@ -97,13 +97,13 @@ int main(int argc, char **argv) {
32
 
33
     static struct option long_opt[] = {
34
         { "socket",               required_argument, 0, 's' },
35
-        { "bar_id",               required_argument, 0, 0 },
36
+        { "bar_id",               required_argument, 0, 'b' },
37
         { "help",                 no_argument,       0, 'h' },
38
         { "version",              no_argument,       0, 'v' },
39
         { NULL,                   0,                 0, 0}
40
     };
41
 
42
-    while ((opt = getopt_long(argc, argv, "s:hv", long_opt, &option_index)) != -1) {
43
+    while ((opt = getopt_long(argc, argv, "b:s:hv", long_opt, &option_index)) != -1) {
44
         switch (opt) {
45
             case 's':
46
                 socket_path = expand_path(optarg);
47
@@ -112,11 +112,8 @@ int main(int argc, char **argv) {
48
                 printf("i3bar version " I3_VERSION " © 2010-2011 Axel Wagner and contributors\n");
49
                 exit(EXIT_SUCCESS);
50
                 break;
51
-            case 0:
52
-                if (!strcmp(long_opt[option_index].name, "bar_id")) {
53
-                    FREE(config.bar_id);
54
-                    config.bar_id = sstrdup(optarg);
55
-                }
56
+            case 'b':
57
+                config.bar_id = sstrdup(optarg);
58
                 break;
59
             default:
60
                 print_usage(argv[0]);