diff options
author | 2016-04-03 16:07:18 +0200 | |
---|---|---|
committer | 2016-04-03 17:14:14 +0200 | |
commit | b6e2b6add9153c0e5e65116e5cbfd0fb99ec1f8f (patch) | |
tree | ad591507825b66a4b456c5296ba511fe0f96e943 /sway | |
parent | Merge pull request #575 from fluxchief/border-color-fix (diff) | |
download | sway-b6e2b6add9153c0e5e65116e5cbfd0fb99ec1f8f.tar.gz sway-b6e2b6add9153c0e5e65116e5cbfd0fb99ec1f8f.tar.zst sway-b6e2b6add9153c0e5e65116e5cbfd0fb99ec1f8f.zip |
Add border color commands
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands.c | 80 |
1 files changed, 79 insertions, 1 deletions
diff --git a/sway/commands.c b/sway/commands.c index c1009f85..b7c1a344 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -45,6 +45,12 @@ static sway_cmd cmd_bar; | |||
45 | static sway_cmd cmd_bindcode; | 45 | static sway_cmd cmd_bindcode; |
46 | static sway_cmd cmd_bindsym; | 46 | static sway_cmd cmd_bindsym; |
47 | static sway_cmd cmd_border; | 47 | static sway_cmd cmd_border; |
48 | static sway_cmd cmd_client_focused; | ||
49 | static sway_cmd cmd_client_focused_inactive; | ||
50 | static sway_cmd cmd_client_unfocused; | ||
51 | static sway_cmd cmd_client_urgent; | ||
52 | static sway_cmd cmd_client_placeholder; | ||
53 | static sway_cmd cmd_client_background; | ||
48 | static sway_cmd cmd_debuglog; | 54 | static sway_cmd cmd_debuglog; |
49 | static sway_cmd cmd_exec; | 55 | static sway_cmd cmd_exec; |
50 | static sway_cmd cmd_exec_always; | 56 | static sway_cmd cmd_exec_always; |
@@ -113,6 +119,8 @@ static sway_cmd bar_colors_cmd_separator; | |||
113 | static sway_cmd bar_colors_cmd_statusline; | 119 | static sway_cmd bar_colors_cmd_statusline; |
114 | static sway_cmd bar_colors_cmd_urgent_workspace; | 120 | static sway_cmd bar_colors_cmd_urgent_workspace; |
115 | 121 | ||
122 | static struct cmd_results *add_color(const char*, char*, const char*); | ||
123 | |||
116 | swayc_t *sp_view; | 124 | swayc_t *sp_view; |
117 | int sp_index = 0; | 125 | int sp_index = 0; |
118 | 126 | ||
@@ -408,6 +416,71 @@ static struct cmd_results *cmd_border(int argc, char **argv) { | |||
408 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 416 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
409 | } | 417 | } |
410 | 418 | ||
419 | static struct cmd_results *parse_border_color(struct border_colors *border_colors, const char *cmd_name, int argc, char **argv) { | ||
420 | struct cmd_results *error = NULL; | ||
421 | if (argc != 5) { | ||
422 | return cmd_results_new(CMD_INVALID, cmd_name, "Requires exact 5 color values"); | ||
423 | } | ||
424 | |||
425 | uint32_t colors[5]; | ||
426 | int i; | ||
427 | for (i = 0; i < 5; i++) { | ||
428 | char buffer[10]; | ||
429 | error = add_color(cmd_name, buffer, argv[i]); | ||
430 | if (error) { | ||
431 | return error; | ||
432 | } | ||
433 | colors[i] = strtoul(buffer+1, NULL, 16); | ||
434 | } | ||
435 | |||
436 | border_colors->border = colors[0]; | ||
437 | border_colors->background = colors[1]; | ||
438 | border_colors->text = colors[2]; | ||
439 | border_colors->indicator = colors[3]; | ||
440 | border_colors->child_border = colors[4]; | ||
441 | |||
442 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
443 | } | ||
444 | |||
445 | static struct cmd_results *cmd_client_focused(int argc, char **argv) { | ||
446 | return parse_border_color(&config->border_colors.focused, "client.focused", argc, argv); | ||
447 | } | ||
448 | |||
449 | static struct cmd_results *cmd_client_focused_inactive(int argc, char **argv) { | ||
450 | return parse_border_color(&config->border_colors.focused_inactive, "client.focused_inactive", argc, argv); | ||
451 | } | ||
452 | |||
453 | static struct cmd_results *cmd_client_unfocused(int argc, char **argv) { | ||
454 | return parse_border_color(&config->border_colors.unfocused, "client.unfocused", argc, argv); | ||
455 | } | ||
456 | |||
457 | static struct cmd_results *cmd_client_urgent(int argc, char **argv) { | ||
458 | return parse_border_color(&config->border_colors.urgent, "client.urgent", argc, argv); | ||
459 | } | ||
460 | |||
461 | static struct cmd_results *cmd_client_placeholder(int argc, char **argv) { | ||
462 | return parse_border_color(&config->border_colors.placeholder, "client.placeholder", argc, argv); | ||
463 | } | ||
464 | |||
465 | static struct cmd_results *cmd_client_background(int argc, char **argv) { | ||
466 | char buffer[10]; | ||
467 | struct cmd_results *error = NULL; | ||
468 | uint32_t background; | ||
469 | |||
470 | if (argc != 1) { | ||
471 | return cmd_results_new(CMD_INVALID, "client.background", "Expect exact 1 value"); | ||
472 | } | ||
473 | |||
474 | error = add_color("client.background", buffer, argv[0]); | ||
475 | if (error) { | ||
476 | return error; | ||
477 | } | ||
478 | |||
479 | background = strtoul(buffer+1, NULL, 16); | ||
480 | config->border_colors.background = background; | ||
481 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
482 | } | ||
483 | |||
411 | static struct cmd_results *cmd_exec_always(int argc, char **argv) { | 484 | static struct cmd_results *cmd_exec_always(int argc, char **argv) { |
412 | struct cmd_results *error = NULL; | 485 | struct cmd_results *error = NULL; |
413 | if (!config->active) return cmd_results_new(CMD_DEFER, NULL, NULL); | 486 | if (!config->active) return cmd_results_new(CMD_DEFER, NULL, NULL); |
@@ -2211,6 +2284,12 @@ static struct cmd_handler handlers[] = { | |||
2211 | { "bindcode", cmd_bindcode }, | 2284 | { "bindcode", cmd_bindcode }, |
2212 | { "bindsym", cmd_bindsym }, | 2285 | { "bindsym", cmd_bindsym }, |
2213 | { "border", cmd_border }, | 2286 | { "border", cmd_border }, |
2287 | { "client.background", cmd_client_background }, | ||
2288 | { "client.focused", cmd_client_focused }, | ||
2289 | { "client.focused_inactive", cmd_client_focused_inactive }, | ||
2290 | { "client.placeholder", cmd_client_placeholder }, | ||
2291 | { "client.unfocused", cmd_client_unfocused }, | ||
2292 | { "client.urgent", cmd_client_urgent }, | ||
2214 | { "debuglog", cmd_debuglog }, | 2293 | { "debuglog", cmd_debuglog }, |
2215 | { "default_orientation", cmd_orientation }, | 2294 | { "default_orientation", cmd_orientation }, |
2216 | { "exec", cmd_exec }, | 2295 | { "exec", cmd_exec }, |
@@ -2821,7 +2900,6 @@ static struct cmd_results *add_color(const char *name, char *buffer, const char | |||
2821 | buffer[7] = 'f'; | 2900 | buffer[7] = 'f'; |
2822 | buffer[8] = 'f'; | 2901 | buffer[8] = 'f'; |
2823 | } | 2902 | } |
2824 | sway_log(L_DEBUG, "Setting %s color %s for bar: %s", name, buffer, config->current_bar->id); | ||
2825 | 2903 | ||
2826 | return NULL; | 2904 | return NULL; |
2827 | } | 2905 | } |