summaryrefslogtreecommitdiff
path: root/sway/commands/client.c
diff options
context:
space:
mode:
authorDrew DeVault <[email protected]>2016-09-02 19:47:37 -0400
committerGitHub <[email protected]>2016-09-02 19:47:37 -0400
commit29820ff826013b595e8c15d9e933767b0c965beb (patch)
treee5bae8ecc19c438091478ad878a8297252c72a81 /sway/commands/client.c
parent4e6d7b125895955e3a84583c6d61f3eb2f8a4fe9 (diff)
parent65ace5dec5c24695501056376e227fb9b1f84a3a (diff)
Merge pull request #879 from zandrmartin/commands-refactor
refactor commands.c
Diffstat (limited to 'sway/commands/client.c')
-rw-r--r--sway/commands/client.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/sway/commands/client.c b/sway/commands/client.c
new file mode 100644
index 00000000..7954f670
--- /dev/null
+++ b/sway/commands/client.c
@@ -0,0 +1,68 @@
+#include <stdlib.h>
+#include <string.h>
+#include "sway/commands.h"
+
+static struct cmd_results *parse_border_color(struct border_colors *border_colors, const char *cmd_name, int argc, char **argv) {
+ struct cmd_results *error = NULL;
+ if (argc != 5) {
+ return cmd_results_new(CMD_INVALID, cmd_name, "Requires exactly five color values");
+ }
+
+ uint32_t colors[5];
+ int i;
+ for (i = 0; i < 5; i++) {
+ char buffer[10];
+ error = add_color(cmd_name, buffer, argv[i]);
+ if (error) {
+ return error;
+ }
+ colors[i] = strtoul(buffer+1, NULL, 16);
+ }
+
+ border_colors->border = colors[0];
+ border_colors->background = colors[1];
+ border_colors->text = colors[2];
+ border_colors->indicator = colors[3];
+ border_colors->child_border = colors[4];
+
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+}
+
+struct cmd_results *cmd_client_focused(int argc, char **argv) {
+ return parse_border_color(&config->border_colors.focused, "client.focused", argc, argv);
+}
+
+struct cmd_results *cmd_client_focused_inactive(int argc, char **argv) {
+ return parse_border_color(&config->border_colors.focused_inactive, "client.focused_inactive", argc, argv);
+}
+
+struct cmd_results *cmd_client_unfocused(int argc, char **argv) {
+ return parse_border_color(&config->border_colors.unfocused, "client.unfocused", argc, argv);
+}
+
+struct cmd_results *cmd_client_urgent(int argc, char **argv) {
+ return parse_border_color(&config->border_colors.urgent, "client.urgent", argc, argv);
+}
+
+struct cmd_results *cmd_client_placeholder(int argc, char **argv) {
+ return parse_border_color(&config->border_colors.placeholder, "client.placeholder", argc, argv);
+}
+
+struct cmd_results *cmd_client_background(int argc, char **argv) {
+ char buffer[10];
+ struct cmd_results *error = NULL;
+ uint32_t background;
+
+ if (argc != 1) {
+ return cmd_results_new(CMD_INVALID, "client.background", "Requires exactly one color value");
+ }
+
+ error = add_color("client.background", buffer, argv[0]);
+ if (error) {
+ return error;
+ }
+
+ background = strtoul(buffer+1, NULL, 16);
+ config->border_colors.background = background;
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+}