diff options
author | Tony Crisci <tony@dubstepdish.com> | 2017-12-14 11:11:56 -0500 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2017-12-14 11:11:56 -0500 |
commit | 92fef27eaa0b52c9d37bdabff14ae21cd6660f46 (patch) | |
tree | 7a923bbbc233079006597d82721117bae88b6ac6 /sway/commands | |
parent | seat configuration (diff) | |
download | sway-92fef27eaa0b52c9d37bdabff14ae21cd6660f46.tar.gz sway-92fef27eaa0b52c9d37bdabff14ae21cd6660f46.tar.zst sway-92fef27eaa0b52c9d37bdabff14ae21cd6660f46.zip |
basic configuration
Diffstat (limited to 'sway/commands')
-rw-r--r-- | sway/commands/input/seat.c | 28 | ||||
-rw-r--r-- | sway/commands/seat.c | 35 | ||||
-rw-r--r-- | sway/commands/seat/attach.c | 26 |
3 files changed, 61 insertions, 28 deletions
diff --git a/sway/commands/input/seat.c b/sway/commands/input/seat.c deleted file mode 100644 index 9d86ac0e..00000000 --- a/sway/commands/input/seat.c +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | #define _XOPEN_SOURCE 700 | ||
2 | #include <string.h> | ||
3 | #include <strings.h> | ||
4 | #include "sway/commands.h" | ||
5 | #include "sway/input/input-manager.h" | ||
6 | #include "log.h" | ||
7 | |||
8 | struct cmd_results *input_cmd_seat(int argc, char **argv) { | ||
9 | sway_log(L_DEBUG, "seat for device: %d %s", | ||
10 | current_input_config==NULL, current_input_config->identifier); | ||
11 | struct cmd_results *error = NULL; | ||
12 | if ((error = checkarg(argc, "seat", EXPECTED_AT_LEAST, 1))) { | ||
13 | return error; | ||
14 | } | ||
15 | if (!current_input_config) { | ||
16 | return cmd_results_new(CMD_FAILURE, "seat", | ||
17 | "No input device defined."); | ||
18 | } | ||
19 | struct input_config *new_config = | ||
20 | new_input_config(current_input_config->identifier); | ||
21 | |||
22 | // TODO validate seat name | ||
23 | free(new_config->seat); | ||
24 | new_config->seat = strdup(argv[0]); | ||
25 | |||
26 | input_cmd_apply(new_config); | ||
27 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
28 | } | ||
diff --git a/sway/commands/seat.c b/sway/commands/seat.c new file mode 100644 index 00000000..4f9e259b --- /dev/null +++ b/sway/commands/seat.c | |||
@@ -0,0 +1,35 @@ | |||
1 | #include <string.h> | ||
2 | #include <strings.h> | ||
3 | #include "sway/commands.h" | ||
4 | #include "sway/input/input-manager.h" | ||
5 | #include "log.h" | ||
6 | |||
7 | struct cmd_results *cmd_seat(int argc, char **argv) { | ||
8 | struct cmd_results *error = NULL; | ||
9 | if ((error = checkarg(argc, "seat", EXPECTED_AT_LEAST, 2))) { | ||
10 | return error; | ||
11 | } | ||
12 | |||
13 | if (config->reading && strcmp("{", argv[1]) == 0) { | ||
14 | current_seat_config = new_seat_config(argv[0]); | ||
15 | sway_log(L_DEBUG, "entering seat block: %s", current_seat_config->name); | ||
16 | return cmd_results_new(CMD_BLOCK_SEAT, NULL, NULL); | ||
17 | } | ||
18 | |||
19 | if (argc > 2) { | ||
20 | int argc_new = argc-2; | ||
21 | char **argv_new = argv+2; | ||
22 | |||
23 | struct cmd_results *res; | ||
24 | current_seat_config = new_seat_config(argv[0]); | ||
25 | if (strcasecmp("attach", argv[1]) == 0) { | ||
26 | res = seat_cmd_attach(argc_new, argv_new); | ||
27 | } else { | ||
28 | res = cmd_results_new(CMD_INVALID, "seat <name>", "Unknown command %s", argv[1]); | ||
29 | } | ||
30 | current_seat_config = NULL; | ||
31 | return res; | ||
32 | } | ||
33 | |||
34 | return cmd_results_new(CMD_BLOCK_SEAT, NULL, NULL); | ||
35 | } | ||
diff --git a/sway/commands/seat/attach.c b/sway/commands/seat/attach.c new file mode 100644 index 00000000..996c1bda --- /dev/null +++ b/sway/commands/seat/attach.c | |||
@@ -0,0 +1,26 @@ | |||
1 | #define _XOPEN_SOURCE 700 | ||
2 | #include <string.h> | ||
3 | #include <strings.h> | ||
4 | #include "sway/input/input-manager.h" | ||
5 | #include "sway/commands.h" | ||
6 | #include "sway/config.h" | ||
7 | #include "log.h" | ||
8 | #include "stringop.h" | ||
9 | |||
10 | struct cmd_results *seat_cmd_attach(int argc, char **argv) { | ||
11 | struct cmd_results *error = NULL; | ||
12 | if ((error = checkarg(argc, "attach", EXPECTED_AT_LEAST, 1))) { | ||
13 | return error; | ||
14 | } | ||
15 | if (!current_seat_config) { | ||
16 | return cmd_results_new(CMD_FAILURE, "attach", "No seat defined"); | ||
17 | } | ||
18 | |||
19 | struct seat_config *new_config = new_seat_config(current_seat_config->name); | ||
20 | struct seat_attachment_config *new_attachment = seat_attachment_config_new(); | ||
21 | new_attachment->identifier = strdup(argv[0]); | ||
22 | list_add(new_config->attachments, new_attachment); | ||
23 | |||
24 | seat_cmd_apply(new_config); | ||
25 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
26 | } | ||