i3 - improved tiling WM


Allocate and expose per-instance pointers for plugins

Patch status: merged

Patch by Alexander Monakov

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

b/i3status.c

14
@@ -56,6 +56,8 @@ static bool exit_upon_signal = false;
15
 
16
 cfg_t *cfg, *cfg_general, *cfg_section;
17
 
18
+void **cur_instance;
19
+
20
 /*
21
  * Set the exit_upon_signal flag, because one cannot do anything in a safe
22
  * manner in a signal handler (e.g. fprintf, which we really want to do for
23
@@ -550,6 +552,8 @@ int main(int argc, char *argv[]) {
24
          * (!), not individual plugins, seem very unlikely. */
25
         char buffer[4096];
26
 
27
+        void **per_instance = calloc(cfg_size(cfg, "order"), sizeof(*per_instance));
28
+
29
         while (1) {
30
                 if (exit_upon_signal) {
31
                         fprintf(stderr, "Exiting due to signal.\n");
32
@@ -563,6 +567,7 @@ int main(int argc, char *argv[]) {
33
                         /* Restore the cursor-position, clear line */
34
                         printf("\033[u\033[K");
35
                 for (j = 0; j < cfg_size(cfg, "order"); j++) {
36
+                        cur_instance = per_instance + j;
37
                         if (j > 0)
38
                                 print_separator(separator);
39
 

b/include/i3status.h

44
@@ -198,4 +198,6 @@ extern int general_socket;
45
 
46
 extern cfg_t *cfg, *cfg_general, *cfg_section;
47
 
48
+extern void **cur_instance;
49
+
50
 #endif