]> git.sur5r.net Git - i3/i3/blobdiff - i3bar/src/config.c
Optionally change i3bar color on focused output, implements #2020
[i3/i3] / i3bar / src / config.c
index a59dd5c1edfcf9bf3f400ee795588befe0f63a7a..6476d15f44f6c34023612ff4de184a04e268ef3d 100644 (file)
@@ -30,10 +30,7 @@ static bool parsing_bindings;
  */
 static int config_map_key_cb(void *params_, const unsigned char *keyVal, size_t keyLen) {
     FREE(cur_key);
-
-    cur_key = smalloc(sizeof(unsigned char) * (keyLen + 1));
-    strncpy(cur_key, (const char *)keyVal, keyLen);
-    cur_key[keyLen] = '\0';
+    sasprintf(&(cur_key), "%.*s", keyLen, keyVal);
 
     if (strcmp(cur_key, "bindings") == 0)
         parsing_bindings = true;
@@ -146,7 +143,7 @@ static int config_string_cb(void *params_, const unsigned char *val, size_t _len
      * users updating from that version and restarting i3bar before i3. */
     if (!strcmp(cur_key, "wheel_up_cmd")) {
         DLOG("wheel_up_cmd = %.*s\n", len, val);
-        binding_t *binding = scalloc(sizeof(binding_t));
+        binding_t *binding = scalloc(1, sizeof(binding_t));
         binding->input_code = 4;
         sasprintf(&(binding->command), "%.*s", len, val);
         TAILQ_INSERT_TAIL(&(config.bindings), binding, bindings);
@@ -157,7 +154,7 @@ static int config_string_cb(void *params_, const unsigned char *val, size_t _len
      * users updating from that version and restarting i3bar before i3. */
     if (!strcmp(cur_key, "wheel_down_cmd")) {
         DLOG("wheel_down_cmd = %.*s\n", len, val);
-        binding_t *binding = scalloc(sizeof(binding_t));
+        binding_t *binding = scalloc(1, sizeof(binding_t));
         binding->input_code = 5;
         sasprintf(&(binding->command), "%.*s", len, val);
         TAILQ_INSERT_TAIL(&(config.bindings), binding, bindings);
@@ -217,6 +214,9 @@ static int config_string_cb(void *params_, const unsigned char *val, size_t _len
     COLOR(statusline, bar_fg);
     COLOR(background, bar_bg);
     COLOR(separator, sep_fg);
+    COLOR(focused_statusline, focus_bar_fg);
+    COLOR(focused_background, focus_bar_bg);
+    COLOR(focused_separator, focus_sep_fg);
     COLOR(focused_workspace_border, focus_ws_border);
     COLOR(focused_workspace_bg, focus_ws_bg);
     COLOR(focused_workspace_text, focus_ws_fg);
@@ -277,7 +277,7 @@ static int config_boolean_cb(void *params_, int val) {
 static int config_integer_cb(void *params_, long long val) {
     if (parsing_bindings) {
         if (strcmp(cur_key, "input_code") == 0) {
-            binding_t *binding = scalloc(sizeof(binding_t));
+            binding_t *binding = scalloc(1, sizeof(binding_t));
             binding->input_code = val;
             TAILQ_INSERT_TAIL(&(config.bindings), binding, bindings);
 
@@ -288,6 +288,12 @@ static int config_integer_cb(void *params_, long long val) {
         return 0;
     }
 
+    if (!strcmp(cur_key, "tray_padding")) {
+        DLOG("tray_padding = %lld\n", val);
+        config.tray_padding = val;
+        return 1;
+    }
+
     return 0;
 }
 
@@ -340,6 +346,9 @@ void free_colors(struct xcb_color_strings_t *colors) {
     FREE_COLOR(bar_fg);
     FREE_COLOR(bar_bg);
     FREE_COLOR(sep_fg);
+    FREE_COLOR(focus_bar_fg);
+    FREE_COLOR(focus_bar_bg);
+    FREE_COLOR(focus_sep_fg);
     FREE_COLOR(active_ws_fg);
     FREE_COLOR(active_ws_bg);
     FREE_COLOR(active_ws_border);