mirror of
https://github.com/swaywm/sway.git
synced 2024-11-23 08:21:28 +00:00
Merge pull request #318 from mikkeloscar/bar-hidden-state
Implement bar option: hidden_state <hide|show>
This commit is contained in:
commit
fc9908a40a
|
@ -65,6 +65,7 @@ static sway_cmd cmd_sticky;
|
||||||
static sway_cmd cmd_workspace;
|
static sway_cmd cmd_workspace;
|
||||||
static sway_cmd cmd_ws_auto_back_and_forth;
|
static sway_cmd cmd_ws_auto_back_and_forth;
|
||||||
|
|
||||||
|
static sway_cmd bar_cmd_hidden_state;
|
||||||
static sway_cmd bar_cmd_id;
|
static sway_cmd bar_cmd_id;
|
||||||
static sway_cmd bar_cmd_position;
|
static sway_cmd bar_cmd_position;
|
||||||
static sway_cmd bar_cmd_strip_workspace_numbers;
|
static sway_cmd bar_cmd_strip_workspace_numbers;
|
||||||
|
@ -1524,6 +1525,30 @@ static struct cmd_handler handlers[] = {
|
||||||
{ "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth },
|
{ "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static struct cmd_results *bar_cmd_hidden_state(int argc, char **argv) {
|
||||||
|
struct cmd_results *error = NULL;
|
||||||
|
if ((error = checkarg(argc, "hidden_state", EXPECTED_EQUAL_TO, 1))) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *state = argv[0];
|
||||||
|
char *old_state = config->current_bar->hidden_state;
|
||||||
|
|
||||||
|
if (strcasecmp("hide", state) == 0) {
|
||||||
|
config->current_bar->hidden_state = strdup(state);
|
||||||
|
} else if(strcmp("show", state) == 0) {
|
||||||
|
config->current_bar->hidden_state = strdup(state);
|
||||||
|
} else {
|
||||||
|
return cmd_results_new(CMD_INVALID, "hidden_state", "Invalid value %s", state);
|
||||||
|
}
|
||||||
|
|
||||||
|
sway_log(L_DEBUG, "Setting hidden_state: '%s' for bar: %s", state, config->current_bar->id);
|
||||||
|
|
||||||
|
// free old state
|
||||||
|
free(old_state);
|
||||||
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static struct cmd_results *bar_cmd_id(int argc, char **argv) {
|
static struct cmd_results *bar_cmd_id(int argc, char **argv) {
|
||||||
struct cmd_results *error = NULL;
|
struct cmd_results *error = NULL;
|
||||||
if ((error = checkarg(argc, "id", EXPECTED_EQUAL_TO, 1))) {
|
if ((error = checkarg(argc, "id", EXPECTED_EQUAL_TO, 1))) {
|
||||||
|
@ -1661,7 +1686,7 @@ static struct cmd_handler bar_handlers[] = {
|
||||||
{ "bindsym", NULL },
|
{ "bindsym", NULL },
|
||||||
{ "colors", NULL },
|
{ "colors", NULL },
|
||||||
{ "font", NULL },
|
{ "font", NULL },
|
||||||
{ "hidden_state", NULL },
|
{ "hidden_state", bar_cmd_hidden_state },
|
||||||
{ "id", bar_cmd_id },
|
{ "id", bar_cmd_id },
|
||||||
{ "mode", NULL },
|
{ "mode", NULL },
|
||||||
{ "modifier", NULL },
|
{ "modifier", NULL },
|
||||||
|
|
Loading…
Reference in a new issue