| 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 |
/* Matches i3/include/data.h */ |
| 42 |
struct Rect { |
| 43 |
uint32_t x; |
| 44 |
uint32_t y; |
| 45 |
uint32_t width; |
| 46 |
uint32_t height; |
| 47 |
}; |
| 48 |
|
| 49 |
typedef struct config_t { |
| 50 |
uint32_t modifier; |
| 51 |
TAILQ_HEAD(bindings_head, binding_t) bindings; |
| 52 |
position_t position; |
| 53 |
bool verbose; |
| 54 |
uint32_t bar_height; |
| 55 |
struct Rect padding; |
| 56 |
bool transparency; |
| 57 |
struct xcb_color_strings_t colors; |
| 58 |
bool disable_binding_mode_indicator; |
| 59 |
bool disable_ws; |
| 60 |
int ws_min_width; |
| 61 |
bool strip_ws_numbers; |
| 62 |
bool strip_ws_name; |
| 63 |
char *bar_id; |
| 64 |
char *command; |
| 65 |
char *workspace_command; |
| 66 |
char *fontname; |
| 67 |
i3String *separator_symbol; |
| 68 |
TAILQ_HEAD(tray_outputs_head, tray_output_t) tray_outputs; |
| 69 |
int tray_padding; |
| 70 |
int num_outputs; |
| 71 |
char **outputs; |
| 72 |
|
| 73 |
bar_display_mode_t hide_on_modifier; |
| 74 |
|
| 75 |
/* The current hidden_state of the bar, which indicates whether it is hidden or shown */ |
| 76 |
enum { S_HIDE = 0, |
| 77 |
S_SHOW = 1 } hidden_state; |
| 78 |
} config_t; |
| 79 |
|
| 80 |
extern config_t config; |
| 81 |
|
| 82 |
/** |
| 83 |
* Parse the received bar configuration JSON string |
| 84 |
* |
| 85 |
*/ |
| 86 |
void parse_config_json(const unsigned char *json, size_t size); |
| 87 |
|
| 88 |
/** |
| 89 |
* Parse the received bar configuration list. The only usecase right now is to |
| 90 |
* automatically get the first bar id. |
| 91 |
* |
| 92 |
*/ |
| 93 |
void parse_get_first_i3bar_config(const unsigned char *json, size_t size); |
| 94 |
|
| 95 |
/** |
| 96 |
* free()s the color strings as soon as they are not needed anymore. |
| 97 |
* |
| 98 |
*/ |
| 99 |
void free_colors(struct xcb_color_strings_t *colors); |