diff options
Diffstat (limited to 'sway/commands/bar/tray_bindsym.c')
-rw-r--r-- | sway/commands/bar/tray_bindsym.c | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/sway/commands/bar/tray_bindsym.c b/sway/commands/bar/tray_bindsym.c deleted file mode 100644 index 4e57e35e..00000000 --- a/sway/commands/bar/tray_bindsym.c +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | #include <strings.h> | ||
2 | #include "config.h" | ||
3 | #include "sway/commands.h" | ||
4 | #include "sway/config.h" | ||
5 | #include "log.h" | ||
6 | |||
7 | struct cmd_results *bar_cmd_tray_bindsym(int argc, char **argv) { | ||
8 | #if HAVE_TRAY | ||
9 | struct cmd_results *error = NULL; | ||
10 | if ((error = checkarg(argc, "tray_bindsym", EXPECTED_EQUAL_TO, 2))) { | ||
11 | return error; | ||
12 | } | ||
13 | |||
14 | if (!config->current_bar) { | ||
15 | return cmd_results_new(CMD_FAILURE, "No bar defined."); | ||
16 | } | ||
17 | |||
18 | int button = 0; | ||
19 | if (strncasecmp(argv[0], "button", strlen("button")) == 0 && | ||
20 | strlen(argv[0]) == strlen("button0")) { | ||
21 | button = argv[0][strlen("button")] - '0'; | ||
22 | } | ||
23 | if (button < 1 || button > 9) { | ||
24 | return cmd_results_new(CMD_FAILURE, | ||
25 | "[Bar %s] Only buttons 1 to 9 are supported", | ||
26 | config->current_bar->id); | ||
27 | } | ||
28 | |||
29 | static const char *commands[] = { | ||
30 | "ContextMenu", | ||
31 | "Activate", | ||
32 | "SecondaryActivate", | ||
33 | "ScrollDown", | ||
34 | "ScrollLeft", | ||
35 | "ScrollRight", | ||
36 | "ScrollUp", | ||
37 | "nop" | ||
38 | }; | ||
39 | |||
40 | for (size_t i = 0; i < sizeof(commands) / sizeof(commands[0]); ++i) { | ||
41 | if (strcasecmp(argv[1], commands[i]) == 0) { | ||
42 | wlr_log(WLR_DEBUG, "[Bar %s] Binding button %d to %s", | ||
43 | config->current_bar->id, button, commands[i]); | ||
44 | config->current_bar->tray_bindings[button] = commands[i]; | ||
45 | return cmd_results_new(CMD_SUCCESS, NULL); | ||
46 | } | ||
47 | } | ||
48 | |||
49 | return cmd_results_new(CMD_INVALID, | ||
50 | "[Bar %s] Invalid command %s", config->current_bar->id, argv[1]); | ||
51 | #else | ||
52 | return cmd_results_new(CMD_INVALID, | ||
53 | "Sway has been compiled without tray support"); | ||
54 | #endif | ||
55 | } | ||