2011-10-25 22:19:38 +02:00
|
|
|
/*
|
|
|
|
* vim:ts=4:sw=4:expandtab
|
|
|
|
*
|
|
|
|
* i3bar - an xcb-based status- and ws-bar for i3
|
2015-04-04 02:17:56 +02:00
|
|
|
* © 2010 Axel Wagner and contributors (see also: LICENSE)
|
2011-10-25 22:19:38 +02:00
|
|
|
*
|
|
|
|
* config.c: Parses the configuration (received from i3).
|
|
|
|
*
|
|
|
|
*/
|
2013-12-29 03:11:50 +01:00
|
|
|
#pragma once
|
2010-11-04 12:27:10 +01:00
|
|
|
|
|
|
|
#include "common.h"
|
2010-08-26 00:02:35 +02:00
|
|
|
|
2011-02-21 15:47:58 +01:00
|
|
|
typedef enum {
|
2011-10-21 20:59:25 +02:00
|
|
|
POS_NONE = 0,
|
|
|
|
POS_TOP,
|
|
|
|
POS_BOT
|
|
|
|
} position_t;
|
2011-02-21 15:47:58 +01:00
|
|
|
|
2014-01-04 13:18:38 +01:00
|
|
|
/* Bar display mode (hide unless modifier is pressed or show in dock mode or always hide in invisible mode) */
|
2014-06-19 11:20:32 +02:00
|
|
|
typedef enum { M_DOCK = 0,
|
|
|
|
M_HIDE = 1,
|
|
|
|
M_INVISIBLE = 2 } bar_display_mode_t;
|
2014-01-04 13:18:38 +01:00
|
|
|
|
2015-05-23 22:48:29 +02:00
|
|
|
typedef struct binding_t {
|
|
|
|
int input_code;
|
2015-06-13 14:58:41 +02:00
|
|
|
char *command;
|
|
|
|
|
2015-05-23 22:48:29 +02:00
|
|
|
TAILQ_ENTRY(binding_t) bindings;
|
|
|
|
} binding_t;
|
2015-06-13 14:58:41 +02:00
|
|
|
|
2010-08-26 00:02:35 +02:00
|
|
|
typedef struct config_t {
|
2014-06-19 11:20:32 +02:00
|
|
|
int modifier;
|
2015-05-23 22:48:29 +02:00
|
|
|
TAILQ_HEAD(bindings_head, binding_t) bindings;
|
2014-06-19 11:20:32 +02:00
|
|
|
position_t position;
|
|
|
|
int verbose;
|
2011-10-19 23:58:19 +02:00
|
|
|
struct xcb_color_strings_t colors;
|
2014-06-19 11:20:32 +02:00
|
|
|
bool disable_binding_mode_indicator;
|
|
|
|
bool disable_ws;
|
|
|
|
bool strip_ws_numbers;
|
|
|
|
char *bar_id;
|
|
|
|
char *command;
|
|
|
|
char *fontname;
|
2015-03-24 23:07:25 +01:00
|
|
|
i3String *separator_symbol;
|
2014-06-19 11:20:32 +02:00
|
|
|
char *tray_output;
|
|
|
|
int num_outputs;
|
|
|
|
char **outputs;
|
introduced i3 command for changing the hidden state and the mode of i3bar
The hidden_state and mode of each i3bar instance can now be controlled from within i3.
Therefore, two new i3 command were introduced:
_
bar hidden_state show|hide|toggle [<bar_id>]
show: always show the bar
hide: normal hide mode
toggle: toggle between show and hide (individually for each bar)
_
bar mode dock|hide|invisible|toggle [<bar_id>]
hide,dock: like before
invisible: always keep the bar hidden
toggle: toggle between dock and hide (individually for each bar)
This patch introduces a hidden_state ("hidden_state hide|show") in the
barconfig, which indicates the current hidden_state of each i3bar
instance. It only affects the bar when in hide mode. Additionally, a new
invisible mode was introduced. In order to change the hidden_state or
mode of the bar from i3, a barconfig-update event was introduced, for
which a bar can subscribe and the bar then gets notified about the
currently set hidden_state and mode in its barconfig.
For convenience, an id field ("id <bar_id>") was added to the barconfig, where one can
set the desired id for the corresponding bar. If the id is not specified, i3 will
deterministically choose an id; otherwise, with the previous random approach for finding
a new id, which is actually not shared with i3bar, as it would determine its id on
startup, the event-subscription would be destroyed on reload. Still, this issue remains
when manually changing the bar_id in the config and then reloading.
fixes #833, #651
2013-05-25 14:30:00 +02:00
|
|
|
|
2014-01-04 13:18:38 +01:00
|
|
|
bar_display_mode_t hide_on_modifier;
|
introduced i3 command for changing the hidden state and the mode of i3bar
The hidden_state and mode of each i3bar instance can now be controlled from within i3.
Therefore, two new i3 command were introduced:
_
bar hidden_state show|hide|toggle [<bar_id>]
show: always show the bar
hide: normal hide mode
toggle: toggle between show and hide (individually for each bar)
_
bar mode dock|hide|invisible|toggle [<bar_id>]
hide,dock: like before
invisible: always keep the bar hidden
toggle: toggle between dock and hide (individually for each bar)
This patch introduces a hidden_state ("hidden_state hide|show") in the
barconfig, which indicates the current hidden_state of each i3bar
instance. It only affects the bar when in hide mode. Additionally, a new
invisible mode was introduced. In order to change the hidden_state or
mode of the bar from i3, a barconfig-update event was introduced, for
which a bar can subscribe and the bar then gets notified about the
currently set hidden_state and mode in its barconfig.
For convenience, an id field ("id <bar_id>") was added to the barconfig, where one can
set the desired id for the corresponding bar. If the id is not specified, i3 will
deterministically choose an id; otherwise, with the previous random approach for finding
a new id, which is actually not shared with i3bar, as it would determine its id on
startup, the event-subscription would be destroyed on reload. Still, this issue remains
when manually changing the bar_id in the config and then reloading.
fixes #833, #651
2013-05-25 14:30:00 +02:00
|
|
|
|
|
|
|
/* The current hidden_state of the bar, which indicates whether it is hidden or shown */
|
2014-06-19 11:20:32 +02:00
|
|
|
enum { S_HIDE = 0,
|
|
|
|
S_SHOW = 1 } hidden_state;
|
2010-08-26 00:02:35 +02:00
|
|
|
} config_t;
|
|
|
|
|
|
|
|
config_t config;
|
|
|
|
|
2011-10-19 23:58:19 +02:00
|
|
|
/**
|
2015-03-23 20:56:49 +01:00
|
|
|
* Start parsing the received bar configuration JSON string
|
2011-10-19 23:58:19 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
void parse_config_json(char *json);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* free()s the color strings as soon as they are not needed anymore.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void free_colors(struct xcb_color_strings_t *colors);
|