diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-12-14 19:29:02 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-12-14 19:29:02 -0500 |
commit | 9db15e29b105a903d335ede2d1f468f15014d5ce (patch) | |
tree | 30f08e23991b37f1fcc288133f4d5dd2516e410b | |
parent | Merge pull request #322 from mikkeloscar/default-bar-config (diff) | |
parent | Added bar_cmd_status_command (diff) | |
download | sway-9db15e29b105a903d335ede2d1f468f15014d5ce.tar.gz sway-9db15e29b105a903d335ede2d1f468f15014d5ce.tar.zst sway-9db15e29b105a903d335ede2d1f468f15014d5ce.zip |
Merge pull request #323 from gpyh/bar_cmd_status_command
Added bar_cmd_status_command
-rw-r--r-- | sway/commands.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/sway/commands.c b/sway/commands.c index d2499e28..2b28c472 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -70,6 +70,7 @@ static sway_cmd bar_cmd_mode; | |||
70 | static sway_cmd bar_cmd_hidden_state; | 70 | static sway_cmd bar_cmd_hidden_state; |
71 | static sway_cmd bar_cmd_id; | 71 | static sway_cmd bar_cmd_id; |
72 | static sway_cmd bar_cmd_position; | 72 | static sway_cmd bar_cmd_position; |
73 | static sway_cmd bar_cmd_status_command; | ||
73 | static sway_cmd bar_cmd_strip_workspace_numbers; | 74 | static sway_cmd bar_cmd_strip_workspace_numbers; |
74 | static sway_cmd bar_cmd_tray_output; | 75 | static sway_cmd bar_cmd_tray_output; |
75 | static sway_cmd bar_cmd_tray_padding; | 76 | static sway_cmd bar_cmd_tray_padding; |
@@ -1671,6 +1672,23 @@ static struct cmd_results *bar_cmd_position(int argc, char **argv) { | |||
1671 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 1672 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
1672 | } | 1673 | } |
1673 | 1674 | ||
1675 | static struct cmd_results *bar_cmd_status_command(int argc, char **argv) { | ||
1676 | struct cmd_results *error = NULL; | ||
1677 | if ((error = checkarg(argc, "status_command", EXPECTED_AT_LEAST, 1))) { | ||
1678 | return error; | ||
1679 | } | ||
1680 | |||
1681 | if (!config->current_bar) { | ||
1682 | return cmd_results_new(CMD_FAILURE, "status_command", "No bar defined."); | ||
1683 | } | ||
1684 | |||
1685 | free(config->current_bar->status_command); | ||
1686 | config->current_bar->status_command = join_args(argv, argc); | ||
1687 | sway_log(L_DEBUG, "Feeding bar with status command: %s", config->current_bar->status_command); | ||
1688 | |||
1689 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
1690 | } | ||
1691 | |||
1674 | static struct cmd_results *bar_cmd_strip_workspace_numbers(int argc, char **argv) { | 1692 | static struct cmd_results *bar_cmd_strip_workspace_numbers(int argc, char **argv) { |
1675 | struct cmd_results *error = NULL; | 1693 | struct cmd_results *error = NULL; |
1676 | if ((error = checkarg(argc, "strip_workspace_numbers", EXPECTED_EQUAL_TO, 1))) { | 1694 | if ((error = checkarg(argc, "strip_workspace_numbers", EXPECTED_EQUAL_TO, 1))) { |
@@ -1759,7 +1777,7 @@ static struct cmd_handler bar_handlers[] = { | |||
1759 | { "output", NULL }, | 1777 | { "output", NULL }, |
1760 | { "position", bar_cmd_position }, | 1778 | { "position", bar_cmd_position }, |
1761 | { "seperator_symbol", NULL }, | 1779 | { "seperator_symbol", NULL }, |
1762 | { "status_command", NULL }, | 1780 | { "status_command", bar_cmd_status_command }, |
1763 | { "strip_workspace_numbers", bar_cmd_strip_workspace_numbers }, | 1781 | { "strip_workspace_numbers", bar_cmd_strip_workspace_numbers }, |
1764 | { "tray_output", bar_cmd_tray_output }, | 1782 | { "tray_output", bar_cmd_tray_output }, |
1765 | { "tray_padding", bar_cmd_tray_padding }, | 1783 | { "tray_padding", bar_cmd_tray_padding }, |