aboutsummaryrefslogtreecommitdiff
path: root/i3bar/include/configuration.h
blob: c9bae7c32359a179763642f0a6aadd0913607219 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
 * vim:ts=4:sw=4:expandtab
 *
 * i3bar - an xcb-based status- and ws-bar for i3
 * © 2010 Axel Wagner and contributors (see also: LICENSE)
 *
 * config.c: Parses the configuration (received from i3).
 *
 */
#pragma once

#include <config.h>

#include "common.h"

typedef enum {
    POS_NONE = 0,
    POS_TOP,
    POS_BOT
} position_t;

/* Bar display mode (hide unless modifier is pressed or show in dock mode or always hide in invisible mode) */
typedef enum { M_DOCK = 0,
               M_HIDE = 1,
               M_INVISIBLE = 2 } bar_display_mode_t;

typedef struct binding_t {
    int input_code;
    char *command;
    bool release;

    TAILQ_ENTRY(binding_t) bindings;
} binding_t;

typedef struct tray_output_t {
    char *output;

    TAILQ_ENTRY(tray_output_t) tray_outputs;
} tray_output_t;

/* Matches i3/include/data.h */
struct Rect {
    uint32_t x;
    uint32_t y;
    uint32_t width;
    uint32_t height;
};

typedef struct config_t {
    uint32_t modifier;
    TAILQ_HEAD(bindings_head, binding_t) bindings;
    position_t position;
    bool verbose;
    uint32_t bar_height;
    struct Rect padding;
    bool transparency;
    struct xcb_color_strings_t colors;
    bool disable_binding_mode_indicator;
    bool disable_ws;
    int ws_min_width;
    bool strip_ws_numbers;
    bool strip_ws_name;
    char *bar_id;
    char *command;
    char *workspace_command;
    char *fontname;
    i3String *separator_symbol;
    TAILQ_HEAD(tray_outputs_head, tray_output_t) tray_outputs;
    int tray_padding;
    int num_outputs;
    char **outputs;

    bar_display_mode_t hide_on_modifier;

    /* The current hidden_state of the bar, which indicates whether it is hidden or shown */
    enum { S_HIDE = 0,
           S_SHOW = 1 } hidden_state;
} config_t;

extern config_t config;

/**
 * Parse the received bar configuration JSON string
 *
 */
void parse_config_json(const unsigned char *json, size_t size);

/**
 * Parse the received bar configuration list. The only usecase right now is to
 * automatically get the first bar id.
 *
 */
void parse_get_first_i3bar_config(const unsigned char *json, size_t size);

/**
 * free()s the color strings as soon as they are not needed anymore.
 *
 */
void free_colors(struct xcb_color_strings_t *colors);