diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-03-29 17:20:03 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-03-29 22:11:08 -0400 |
commit | bf7a4cd0ebd465a0597e9eec0142fad222b396de (patch) | |
tree | f95c4b8cd8e7d06eaa1b688d3bcbb3249dc21129 /sway/commands/bar/modifier.c | |
parent | Implement enough IPC for swaybar to work (diff) | |
download | sway-bf7a4cd0ebd465a0597e9eec0142fad222b396de.tar.gz sway-bf7a4cd0ebd465a0597e9eec0142fad222b396de.tar.zst sway-bf7a4cd0ebd465a0597e9eec0142fad222b396de.zip |
Add bar configuration commands
Diffstat (limited to 'sway/commands/bar/modifier.c')
-rw-r--r-- | sway/commands/bar/modifier.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/sway/commands/bar/modifier.c b/sway/commands/bar/modifier.c new file mode 100644 index 00000000..9a1f8b01 --- /dev/null +++ b/sway/commands/bar/modifier.c | |||
@@ -0,0 +1,35 @@ | |||
1 | #include <string.h> | ||
2 | #include "sway/commands.h" | ||
3 | #include "log.h" | ||
4 | #include "stringop.h" | ||
5 | #include "util.h" | ||
6 | |||
7 | struct cmd_results *bar_cmd_modifier(int argc, char **argv) { | ||
8 | struct cmd_results *error = NULL; | ||
9 | if ((error = checkarg(argc, "modifier", EXPECTED_EQUAL_TO, 1))) { | ||
10 | return error; | ||
11 | } | ||
12 | |||
13 | if (!config->current_bar) { | ||
14 | return cmd_results_new(CMD_FAILURE, "modifier", "No bar defined."); | ||
15 | } | ||
16 | |||
17 | uint32_t mod = 0; | ||
18 | |||
19 | list_t *split = split_string(argv[0], "+"); | ||
20 | for (int i = 0; i < split->length; ++i) { | ||
21 | uint32_t tmp_mod; | ||
22 | if ((tmp_mod = get_modifier_mask_by_name(split->items[i])) > 0) { | ||
23 | mod |= tmp_mod; | ||
24 | continue; | ||
25 | } else { | ||
26 | free_flat_list(split); | ||
27 | return cmd_results_new(CMD_INVALID, "modifier", "Unknown modifier '%s'", split->items[i]); | ||
28 | } | ||
29 | } | ||
30 | free_flat_list(split); | ||
31 | |||
32 | config->current_bar->modifier = mod; | ||
33 | wlr_log(L_DEBUG, "Show/Hide the bar when pressing '%s' in hide mode.", argv[0]); | ||
34 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
35 | } | ||