From 0a8ec2638338c856adeb3c411d9d01b50eb9ce1e Mon Sep 17 00:00:00 2001 From: Mikkel Oscar Lyderik Date: Mon, 14 Dec 2015 00:00:11 +0100 Subject: [PATCH] Implement bar option: tray_padding [px] --- sway/commands.c | 28 +++++++++++++++++++++++++++- sway/config.c | 1 + 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/sway/commands.c b/sway/commands.c index cefad2efe..4e9d27964 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -63,6 +63,8 @@ static sway_cmd cmd_splitv; 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_padding; static sway_cmd bar_cmd_workspace_buttons; swayc_t *sp_view; @@ -1519,6 +1521,30 @@ static struct cmd_handler handlers[] = { { "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth }, }; +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))) { + return error; + } + + if (!config->current_bar) { + return cmd_results_new(CMD_FAILURE, "tray_padding", "No bar defined."); + } + + int padding = atoi(argv[0]); + if (padding < 0) { + return cmd_results_new(CMD_INVALID, "tray_padding", + "Invalid padding value %s, minimum is 0", argv[0]); + } + + if (argc > 1 && strcasecmp("px", argv[1]) != 0) { + return cmd_results_new(CMD_INVALID, "tray_padding", + "Unknown unit %s", argv[1]); + } + config->current_bar->tray_padding = padding; + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} + static struct cmd_results *bar_cmd_workspace_buttons(int argc, char **argv) { struct cmd_results *error = NULL; if ((error = checkarg(argc, "workspace_buttons", EXPECTED_EQUAL_TO, 1))) { @@ -1555,7 +1581,7 @@ static struct cmd_handler bar_handlers[] = { { "status_command", NULL }, { "strip_workspace_numbers", NULL }, { "tray_output", NULL }, - { "tray_padding", NULL }, + { "tray_padding", bar_cmd_tray_padding }, { "workspace_buttons", bar_cmd_workspace_buttons }, }; diff --git a/sway/config.c b/sway/config.c index d5b75adfe..bb7ecf9e5 100644 --- a/sway/config.c +++ b/sway/config.c @@ -144,6 +144,7 @@ static void config_defaults(struct sway_config *config) { config->bar.workspace_buttons = true; config->bar.strip_workspace_numbers = false; config->bar.binding_mode_indicator = true; + config->bar.tray_padding = 2; } static char *get_config_path(void) {