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
This commit is contained in:
committed by
Michael Stapelberg
parent
f0eba6d15c
commit
e3913093b6
@ -452,7 +452,15 @@ CFGFUN(bar_font, const char *font) {
|
||||
}
|
||||
|
||||
CFGFUN(bar_mode, const char *mode) {
|
||||
current_bar.mode = (strcmp(mode, "hide") == 0 ? M_HIDE : M_DOCK);
|
||||
current_bar.mode = (strcmp(mode, "dock") == 0 ? M_DOCK : (strcmp(mode, "hide") == 0 ? M_HIDE : M_INVISIBLE));
|
||||
}
|
||||
|
||||
CFGFUN(bar_hidden_state, const char *hidden_state) {
|
||||
current_bar.hidden_state = (strcmp(hidden_state, "hide") == 0 ? S_HIDE : S_SHOW);
|
||||
}
|
||||
|
||||
CFGFUN(bar_id, const char *bar_id) {
|
||||
current_bar.id = sstrdup(bar_id);
|
||||
}
|
||||
|
||||
CFGFUN(bar_output, const char *output) {
|
||||
@ -548,15 +556,11 @@ CFGFUN(bar_workspace_buttons, const char *value) {
|
||||
|
||||
CFGFUN(bar_finish) {
|
||||
DLOG("\t new bar configuration finished, saving.\n");
|
||||
/* Generate a unique ID for this bar */
|
||||
current_bar.id = sstrdup("bar-XXXXXX");
|
||||
/* This works similar to mktemp in that it replaces the last six X with
|
||||
* random letters, but without the restriction that the given buffer
|
||||
* has to contain a valid path name. */
|
||||
char *x = current_bar.id + strlen("bar-");
|
||||
while (*x != '\0') {
|
||||
*(x++) = (rand() % 26) + 'a';
|
||||
}
|
||||
/* Generate a unique ID for this bar if not already configured */
|
||||
if (!current_bar.id)
|
||||
sasprintf(¤t_bar.id, "bar-%d", config.number_barconfigs);
|
||||
|
||||
config.number_barconfigs++;
|
||||
|
||||
/* If no font was explicitly set, we use the i3 font as default */
|
||||
if (!current_bar.font && font_pattern)
|
||||
|
Reference in New Issue
Block a user