From cb9b157e03911a36136b42f189279053612f7e7c Mon Sep 17 00:00:00 2001 From: Mikkel Oscar Lyderik Date: Mon, 14 Dec 2015 14:52:34 +0100 Subject: [PATCH 1/4] Add tray_output not supported warning --- sway/commands.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sway/commands.c b/sway/commands.c index 4e9d2796..aeb14642 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -64,6 +64,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_tray_output; static sway_cmd bar_cmd_tray_padding; static sway_cmd bar_cmd_workspace_buttons; @@ -1521,6 +1522,11 @@ static struct cmd_handler handlers[] = { { "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth }, }; +static struct cmd_results *bar_cmd_tray_output(int argc, char **argv) { + sway_log(L_ERROR, "warning: tray_output is not supported on wayland"); + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} + static struct cmd_results *bar_cmd_tray_padding(int argc, char **argv) { struct cmd_results *error = NULL; if ((error = checkarg(argc, "tray_padding", EXPECTED_AT_LEAST, 1))) { @@ -1580,7 +1586,7 @@ static struct cmd_handler bar_handlers[] = { { "seperator_symbol", NULL }, { "status_command", NULL }, { "strip_workspace_numbers", NULL }, - { "tray_output", NULL }, + { "tray_output", bar_cmd_tray_output }, { "tray_padding", bar_cmd_tray_padding }, { "workspace_buttons", bar_cmd_workspace_buttons }, }; From cc08daded412966ba9068ad9ac63c5adea9ef5d4 Mon Sep 17 00:00:00 2001 From: Mikkel Oscar Lyderik Date: Mon, 14 Dec 2015 14:56:28 +0100 Subject: [PATCH 2/4] Implement bar option: strip_workspace_numbers --- sway/commands.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/sway/commands.c b/sway/commands.c index aeb14642..f5593b05 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -64,6 +64,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_strip_workspace_numbers; static sway_cmd bar_cmd_tray_output; static sway_cmd bar_cmd_tray_padding; static sway_cmd bar_cmd_workspace_buttons; @@ -1522,6 +1523,29 @@ static struct cmd_handler handlers[] = { { "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth }, }; +static struct cmd_results *bar_cmd_strip_workspace_numbers(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "strip_workspace_numbers", EXPECTED_EQUAL_TO, 1))) { + return error; + } + + if (!config->current_bar) { + return cmd_results_new(CMD_FAILURE, "strip_workspace_numbers", "No bar defined."); + } + + if (strcasecmp("yes", argv[0]) == 0) { + config->current_bar->strip_workspace_numbers = true; + sway_log(L_DEBUG, "Stripping workspace numbers on bar"); + } else if (strcasecmp("no", argv[0]) == 0) { + config->current_bar->strip_workspace_numbers = false; + sway_log(L_DEBUG, "Enabling workspace numbers on bar"); + } else { + error = cmd_results_new(CMD_INVALID, "strip_workspace_numbers", "Invalid value %s", argv[0]); + return error; + } + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} + static struct cmd_results *bar_cmd_tray_output(int argc, char **argv) { sway_log(L_ERROR, "warning: tray_output is not supported on wayland"); return cmd_results_new(CMD_SUCCESS, NULL, NULL); @@ -1585,7 +1609,7 @@ static struct cmd_handler bar_handlers[] = { { "position", NULL }, { "seperator_symbol", NULL }, { "status_command", NULL }, - { "strip_workspace_numbers", NULL }, + { "strip_workspace_numbers", bar_cmd_strip_workspace_numbers }, { "tray_output", bar_cmd_tray_output }, { "tray_padding", bar_cmd_tray_padding }, { "workspace_buttons", bar_cmd_workspace_buttons }, From bd0c58e85a2b6c0e7541e7270e6d7bcca940d7ed Mon Sep 17 00:00:00 2001 From: Mikkel Oscar Lyderik Date: Mon, 14 Dec 2015 15:12:05 +0100 Subject: [PATCH 3/4] Implement bar option: position --- sway/commands.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/sway/commands.c b/sway/commands.c index f5593b05..5372d3e9 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -64,6 +64,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_position; static sway_cmd bar_cmd_strip_workspace_numbers; static sway_cmd bar_cmd_tray_output; static sway_cmd bar_cmd_tray_padding; @@ -1523,6 +1524,33 @@ static struct cmd_handler handlers[] = { { "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth }, }; +static struct cmd_results *bar_cmd_position(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "position", EXPECTED_EQUAL_TO, 1))) { + return error; + } + + if (!config->current_bar) { + return cmd_results_new(CMD_FAILURE, "position", "No bar defined."); + } + + if (strcasecmp("top", argv[0]) == 0) { + config->current_bar->position = DESKTOP_SHELL_PANEL_POSITION_TOP; + } else if (strcasecmp("bottom", argv[0]) == 0) { + config->current_bar->position = DESKTOP_SHELL_PANEL_POSITION_BOTTOM; + } else if (strcasecmp("left", argv[0]) == 0) { + config->current_bar->position = DESKTOP_SHELL_PANEL_POSITION_LEFT; + } else if (strcasecmp("right", argv[0]) == 0) { + config->current_bar->position = DESKTOP_SHELL_PANEL_POSITION_RIGHT; + } else { + error = cmd_results_new(CMD_INVALID, "position", "Invalid value %s", argv[0]); + return error; + } + + sway_log(L_DEBUG, "Setting bar position '%s'", argv[0]); + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} + static struct cmd_results *bar_cmd_strip_workspace_numbers(int argc, char **argv) { struct cmd_results *error = NULL; if ((error = checkarg(argc, "strip_workspace_numbers", EXPECTED_EQUAL_TO, 1))) { @@ -1606,7 +1634,7 @@ static struct cmd_handler bar_handlers[] = { { "mode", NULL }, { "modifier", NULL }, { "output", NULL }, - { "position", NULL }, + { "position", bar_cmd_position }, { "seperator_symbol", NULL }, { "status_command", NULL }, { "strip_workspace_numbers", bar_cmd_strip_workspace_numbers }, From b00c106460dfa50959be5fae864d3b10ed4ca1b3 Mon Sep 17 00:00:00 2001 From: Mikkel Oscar Lyderik Date: Mon, 14 Dec 2015 15:24:27 +0100 Subject: [PATCH 4/4] Add more debug logging to bar option parsing --- sway/commands.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sway/commands.c b/sway/commands.c index 5372d3e9..b9cc1a69 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -1600,6 +1600,7 @@ static struct cmd_results *bar_cmd_tray_padding(int argc, char **argv) { "Unknown unit %s", argv[1]); } config->current_bar->tray_padding = padding; + sway_log(L_DEBUG, "Enabling tray padding of %d px", padding); return cmd_results_new(CMD_SUCCESS, NULL, NULL); } @@ -1615,8 +1616,10 @@ static struct cmd_results *bar_cmd_workspace_buttons(int argc, char **argv) { if (strcasecmp("yes", argv[0]) == 0) { config->current_bar->workspace_buttons = true; + sway_log(L_DEBUG, "Enabling workspace buttons on bar"); } else if (strcasecmp("no", argv[0]) == 0) { config->current_bar->workspace_buttons = false; + sway_log(L_DEBUG, "Disabling workspace buttons on bar"); } else { error = cmd_results_new(CMD_INVALID, "workspace_buttons", "Invalid value %s", argv[0]); return error;