diff options
Diffstat (limited to 'sway/commands/client.c')
-rw-r--r-- | sway/commands/client.c | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/sway/commands/client.c b/sway/commands/client.c index e4282341..dd0694df 100644 --- a/sway/commands/client.c +++ b/sway/commands/client.c | |||
@@ -10,30 +10,34 @@ static void rebuild_textures_iterator(struct sway_container *con, void *data) { | |||
10 | container_update_title_textures(con); | 10 | container_update_title_textures(con); |
11 | } | 11 | } |
12 | 12 | ||
13 | static struct cmd_results *handle_command(int argc, char **argv, | 13 | static struct cmd_results *handle_command(int argc, char **argv, char *cmd_name, |
14 | struct border_colors *class, char *cmd_name) { | 14 | struct border_colors *class, const char *default_indicator) { |
15 | struct cmd_results *error = NULL; | 15 | struct cmd_results *error = NULL; |
16 | if ((error = checkarg(argc, cmd_name, EXPECTED_EQUAL_TO, 5))) { | 16 | if ((error = checkarg(argc, cmd_name, EXPECTED_AT_LEAST, 3)) || |
17 | (error = checkarg(argc, cmd_name, EXPECTED_AT_MOST, 5))) { | ||
17 | return error; | 18 | return error; |
18 | } | 19 | } |
19 | 20 | ||
20 | struct border_colors colors = {0}; | 21 | struct border_colors colors = {0}; |
22 | const char *ind_hex = argc > 3 ? argv[3] : default_indicator; | ||
23 | const char *child_hex = argc > 4 ? argv[4] : argv[1]; // def to background | ||
21 | 24 | ||
22 | struct { | 25 | struct { |
23 | const char *name; | 26 | const char *name; |
27 | const char *hex; | ||
24 | float *rgba[4]; | 28 | float *rgba[4]; |
25 | } properties[] = { | 29 | } properties[] = { |
26 | { "border", colors.border }, | 30 | { "border", argv[0], colors.border }, |
27 | { "background", colors.background }, | 31 | { "background", argv[1], colors.background }, |
28 | { "text", colors.text }, | 32 | { "text", argv[2], colors.text }, |
29 | { "indicator", colors.indicator }, | 33 | { "indicator", ind_hex, colors.indicator }, |
30 | { "child_border", colors.child_border } | 34 | { "child_border", child_hex, colors.child_border } |
31 | }; | 35 | }; |
32 | for (size_t i = 0; i < sizeof(properties) / sizeof(properties[0]); i++) { | 36 | for (size_t i = 0; i < sizeof(properties) / sizeof(properties[0]); i++) { |
33 | uint32_t color; | 37 | uint32_t color; |
34 | if (!parse_color(argv[i], &color)) { | 38 | if (!parse_color(properties[i].hex, &color)) { |
35 | return cmd_results_new(CMD_INVALID, | 39 | return cmd_results_new(CMD_INVALID, "Invalid %s color %s", |
36 | "Invalid %s color %s", properties[i].name, argv[i]); | 40 | properties[i].name, properties[i].hex); |
37 | } | 41 | } |
38 | color_to_rgba(*properties[i].rgba, color); | 42 | color_to_rgba(*properties[i].rgba, color); |
39 | } | 43 | } |
@@ -53,19 +57,23 @@ static struct cmd_results *handle_command(int argc, char **argv, | |||
53 | } | 57 | } |
54 | 58 | ||
55 | struct cmd_results *cmd_client_focused(int argc, char **argv) { | 59 | struct cmd_results *cmd_client_focused(int argc, char **argv) { |
56 | return handle_command(argc, argv, &config->border_colors.focused, "client.focused"); | 60 | return handle_command(argc, argv, "client.focused", |
61 | &config->border_colors.focused, "#2e9ef4ff"); | ||
57 | } | 62 | } |
58 | 63 | ||
59 | struct cmd_results *cmd_client_focused_inactive(int argc, char **argv) { | 64 | struct cmd_results *cmd_client_focused_inactive(int argc, char **argv) { |
60 | return handle_command(argc, argv, &config->border_colors.focused_inactive, "client.focused_inactive"); | 65 | return handle_command(argc, argv, "client.focused_inactive", |
66 | &config->border_colors.focused_inactive, "#484e50ff"); | ||
61 | } | 67 | } |
62 | 68 | ||
63 | struct cmd_results *cmd_client_unfocused(int argc, char **argv) { | 69 | struct cmd_results *cmd_client_unfocused(int argc, char **argv) { |
64 | return handle_command(argc, argv, &config->border_colors.unfocused, "client.unfocused"); | 70 | return handle_command(argc, argv, "client.unfocused", |
71 | &config->border_colors.unfocused, "#292d2eff"); | ||
65 | } | 72 | } |
66 | 73 | ||
67 | struct cmd_results *cmd_client_urgent(int argc, char **argv) { | 74 | struct cmd_results *cmd_client_urgent(int argc, char **argv) { |
68 | return handle_command(argc, argv, &config->border_colors.urgent, "client.urgent"); | 75 | return handle_command(argc, argv, "client.urgent", |
76 | &config->border_colors.urgent, "#900000ff"); | ||
69 | } | 77 | } |
70 | 78 | ||
71 | struct cmd_results *cmd_client_noop(int argc, char **argv) { | 79 | struct cmd_results *cmd_client_noop(int argc, char **argv) { |