basic configuration

This commit is contained in:
Tony Crisci 2017-12-14 11:11:56 -05:00
parent c173d30b92
commit 92fef27eaa
15 changed files with 543 additions and 174 deletions

View file

@ -1,28 +0,0 @@
#define _XOPEN_SOURCE 700
#include <string.h>
#include <strings.h>
#include "sway/commands.h"
#include "sway/input/input-manager.h"
#include "log.h"
struct cmd_results *input_cmd_seat(int argc, char **argv) {
sway_log(L_DEBUG, "seat for device: %d %s",
current_input_config==NULL, current_input_config->identifier);
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "seat", EXPECTED_AT_LEAST, 1))) {
return error;
}
if (!current_input_config) {
return cmd_results_new(CMD_FAILURE, "seat",
"No input device defined.");
}
struct input_config *new_config =
new_input_config(current_input_config->identifier);
// TODO validate seat name
free(new_config->seat);
new_config->seat = strdup(argv[0]);
input_cmd_apply(new_config);
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}

35
sway/commands/seat.c Normal file
View file

@ -0,0 +1,35 @@
#include <string.h>
#include <strings.h>
#include "sway/commands.h"
#include "sway/input/input-manager.h"
#include "log.h"
struct cmd_results *cmd_seat(int argc, char **argv) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "seat", EXPECTED_AT_LEAST, 2))) {
return error;
}
if (config->reading && strcmp("{", argv[1]) == 0) {
current_seat_config = new_seat_config(argv[0]);
sway_log(L_DEBUG, "entering seat block: %s", current_seat_config->name);
return cmd_results_new(CMD_BLOCK_SEAT, NULL, NULL);
}
if (argc > 2) {
int argc_new = argc-2;
char **argv_new = argv+2;
struct cmd_results *res;
current_seat_config = new_seat_config(argv[0]);
if (strcasecmp("attach", argv[1]) == 0) {
res = seat_cmd_attach(argc_new, argv_new);
} else {
res = cmd_results_new(CMD_INVALID, "seat <name>", "Unknown command %s", argv[1]);
}
current_seat_config = NULL;
return res;
}
return cmd_results_new(CMD_BLOCK_SEAT, NULL, NULL);
}

View file

@ -0,0 +1,26 @@
#define _XOPEN_SOURCE 700
#include <string.h>
#include <strings.h>
#include "sway/input/input-manager.h"
#include "sway/commands.h"
#include "sway/config.h"
#include "log.h"
#include "stringop.h"
struct cmd_results *seat_cmd_attach(int argc, char **argv) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "attach", EXPECTED_AT_LEAST, 1))) {
return error;
}
if (!current_seat_config) {
return cmd_results_new(CMD_FAILURE, "attach", "No seat defined");
}
struct seat_config *new_config = new_seat_config(current_seat_config->name);
struct seat_attachment_config *new_attachment = seat_attachment_config_new();
new_attachment->identifier = strdup(argv[0]);
list_add(new_config->attachments, new_attachment);
seat_cmd_apply(new_config);
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}