aboutsummaryrefslogtreecommitdiff
path: root/sway/commands.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2015-12-14 13:59:11 -0500
committerDrew DeVault <sir@cmpwn.com>2015-12-14 13:59:11 -0500
commitfc9908a40a6c09504eeb35a2cab17b5d80a5fab6 (patch)
treec688d55076772f7b8c8e42492be3fa580256cc3d /sway/commands.c
parent966971f07dd62949dd5639403308b892e3bd4f29 (diff)
parentd6cd37d87346e4f1b89219a04e790dac1e1dfdfe (diff)
Merge pull request #318 from mikkeloscar/bar-hidden-state
Implement bar option: hidden_state <hide|show>
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 7eb076c4..6d40344d 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -65,6 +65,7 @@ static sway_cmd cmd_sticky;
static sway_cmd cmd_workspace;
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_position;
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 },
};
+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) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "id", EXPECTED_EQUAL_TO, 1))) {
@@ -1661,7 +1686,7 @@ static struct cmd_handler bar_handlers[] = {
{ "bindsym", NULL },
{ "colors", NULL },
{ "font", NULL },
- { "hidden_state", NULL },
+ { "hidden_state", bar_cmd_hidden_state },
{ "id", bar_cmd_id },
{ "mode", NULL },
{ "modifier", NULL },