diff options
author | 2015-12-14 00:00:11 +0100 | |
---|---|---|
committer | 2015-12-14 12:56:59 +0100 | |
commit | 0a8ec2638338c856adeb3c411d9d01b50eb9ce1e (patch) | |
tree | 62e68de931dcb0ae0e902c78ddf509e67faa5f6f /sway | |
parent | Implement bar option: workspace_buttons <yes|no> (diff) | |
download | sway-0a8ec2638338c856adeb3c411d9d01b50eb9ce1e.tar.gz sway-0a8ec2638338c856adeb3c411d9d01b50eb9ce1e.tar.zst sway-0a8ec2638338c856adeb3c411d9d01b50eb9ce1e.zip |
Implement bar option: tray_padding <px> [px]
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands.c | 28 | ||||
-rw-r--r-- | sway/config.c | 1 |
2 files changed, 28 insertions, 1 deletions
diff --git a/sway/commands.c b/sway/commands.c index cefad2ef..4e9d2796 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -63,6 +63,8 @@ static sway_cmd cmd_splitv; | |||
63 | static sway_cmd cmd_sticky; | 63 | static sway_cmd cmd_sticky; |
64 | static sway_cmd cmd_workspace; | 64 | static sway_cmd cmd_workspace; |
65 | static sway_cmd cmd_ws_auto_back_and_forth; | 65 | static sway_cmd cmd_ws_auto_back_and_forth; |
66 | |||
67 | static sway_cmd bar_cmd_tray_padding; | ||
66 | static sway_cmd bar_cmd_workspace_buttons; | 68 | static sway_cmd bar_cmd_workspace_buttons; |
67 | 69 | ||
68 | swayc_t *sp_view; | 70 | swayc_t *sp_view; |
@@ -1519,6 +1521,30 @@ static struct cmd_handler handlers[] = { | |||
1519 | { "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth }, | 1521 | { "workspace_auto_back_and_forth", cmd_ws_auto_back_and_forth }, |
1520 | }; | 1522 | }; |
1521 | 1523 | ||
1524 | static struct cmd_results *bar_cmd_tray_padding(int argc, char **argv) { | ||
1525 | struct cmd_results *error = NULL; | ||
1526 | if ((error = checkarg(argc, "tray_padding", EXPECTED_AT_LEAST, 1))) { | ||
1527 | return error; | ||
1528 | } | ||
1529 | |||
1530 | if (!config->current_bar) { | ||
1531 | return cmd_results_new(CMD_FAILURE, "tray_padding", "No bar defined."); | ||
1532 | } | ||
1533 | |||
1534 | int padding = atoi(argv[0]); | ||
1535 | if (padding < 0) { | ||
1536 | return cmd_results_new(CMD_INVALID, "tray_padding", | ||
1537 | "Invalid padding value %s, minimum is 0", argv[0]); | ||
1538 | } | ||
1539 | |||
1540 | if (argc > 1 && strcasecmp("px", argv[1]) != 0) { | ||
1541 | return cmd_results_new(CMD_INVALID, "tray_padding", | ||
1542 | "Unknown unit %s", argv[1]); | ||
1543 | } | ||
1544 | config->current_bar->tray_padding = padding; | ||
1545 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
1546 | } | ||
1547 | |||
1522 | static struct cmd_results *bar_cmd_workspace_buttons(int argc, char **argv) { | 1548 | static struct cmd_results *bar_cmd_workspace_buttons(int argc, char **argv) { |
1523 | struct cmd_results *error = NULL; | 1549 | struct cmd_results *error = NULL; |
1524 | if ((error = checkarg(argc, "workspace_buttons", EXPECTED_EQUAL_TO, 1))) { | 1550 | if ((error = checkarg(argc, "workspace_buttons", EXPECTED_EQUAL_TO, 1))) { |
@@ -1555,7 +1581,7 @@ static struct cmd_handler bar_handlers[] = { | |||
1555 | { "status_command", NULL }, | 1581 | { "status_command", NULL }, |
1556 | { "strip_workspace_numbers", NULL }, | 1582 | { "strip_workspace_numbers", NULL }, |
1557 | { "tray_output", NULL }, | 1583 | { "tray_output", NULL }, |
1558 | { "tray_padding", NULL }, | 1584 | { "tray_padding", bar_cmd_tray_padding }, |
1559 | { "workspace_buttons", bar_cmd_workspace_buttons }, | 1585 | { "workspace_buttons", bar_cmd_workspace_buttons }, |
1560 | }; | 1586 | }; |
1561 | 1587 | ||
diff --git a/sway/config.c b/sway/config.c index d5b75adf..bb7ecf9e 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -144,6 +144,7 @@ static void config_defaults(struct sway_config *config) { | |||
144 | config->bar.workspace_buttons = true; | 144 | config->bar.workspace_buttons = true; |
145 | config->bar.strip_workspace_numbers = false; | 145 | config->bar.strip_workspace_numbers = false; |
146 | config->bar.binding_mode_indicator = true; | 146 | config->bar.binding_mode_indicator = true; |
147 | config->bar.tray_padding = 2; | ||
147 | } | 148 | } |
148 | 149 | ||
149 | static char *get_config_path(void) { | 150 | static char *get_config_path(void) { |