1 /*
2  * vim:ts=4:sw=4:expandtab
3  *
4  * i3bar - an xcb-based status- and ws-bar for i3
5  * © 2010 Axel Wagner and contributors (see also: LICENSE)
6  *
7  * config.c: Parses the configuration (received from i3).
8  *
9  */
10 #pragma once
11 
12 #include <config.h>
13 
14 #include "common.h"
15 
16 typedef enum {
17     POS_NONE = 0,
18     POS_TOP,
19     POS_BOT
20 } position_t;
21 
22 /* Bar display mode (hide unless modifier is pressed or show in dock mode or always hide in invisible mode) */
23 typedef enum { M_DOCK = 0,
24                M_HIDE = 1,
25                M_INVISIBLE = 2 } bar_display_mode_t;
26 
27 typedef struct binding_t {
28     int input_code;
29     char *command;
30     bool release;
31 
32     TAILQ_ENTRY(binding_t) bindings;
33 } binding_t;
34 
35 typedef struct tray_output_t {
36     char *output;
37 
38     TAILQ_ENTRY(tray_output_t) tray_outputs;
39 } tray_output_t;
40 
41 typedef struct config_t {
42     uint32_t modifier;
43     TAILQ_HEAD(bindings_head, binding_t) bindings;
44     position_t position;
45     bool verbose;
46     uint32_t bar_height;
47     bool transparency;
48     struct xcb_color_strings_t colors;
49     bool disable_binding_mode_indicator;
50     bool disable_ws;
51     int ws_min_width;
52     bool strip_ws_numbers;
53     bool strip_ws_name;
54     char *bar_id;
55     char *command;
56     char *fontname;
57     i3String *separator_symbol;
58     TAILQ_HEAD(tray_outputs_head, tray_output_t) tray_outputs;
59     int tray_padding;
60     int num_outputs;
61     char **outputs;
62 
63     bar_display_mode_t hide_on_modifier;
64 
65     /* The current hidden_state of the bar, which indicates whether it is hidden or shown */
66     enum { S_HIDE = 0,
67            S_SHOW = 1 } hidden_state;
68 } config_t;
69 
70 extern config_t config;
71 
72 /**
73  * Start parsing the received bar configuration JSON string
74  *
75  */
76 void parse_config_json(char *json);
77 
78 /**
79  * Start parsing the received bar configuration list. The only usecase right
80  * now is to automatically get the first bar id.
81  *
82  */
83 void parse_get_first_i3bar_config(char *json);
84 
85 /**
86  * free()s the color strings as soon as they are not needed anymore.
87  *
88  */
89 void free_colors(struct xcb_color_strings_t *colors);
90