aboutsummaryrefslogtreecommitdiffstats
path: root/swaylock
diff options
context:
space:
mode:
authorLibravatar Calvin Lee <cyrus296@gmail.com>2017-02-21 21:14:28 -0700
committerLibravatar Calvin Lee <cyrus296@gmail.com>2017-02-21 21:17:01 -0700
commit46bd2bb5df02bd155bf92af6483c5b553afa7b6e (patch)
treebcf73696840c9ab3289e2e46fb8c0f8e8253fa2c /swaylock
parentFeature for #1078: Configurable swaylock colors (diff)
downloadsway-46bd2bb5df02bd155bf92af6483c5b553afa7b6e.tar.gz
sway-46bd2bb5df02bd155bf92af6483c5b553afa7b6e.tar.zst
sway-46bd2bb5df02bd155bf92af6483c5b553afa7b6e.zip
Documentation and style fixes for swaylock
Diffstat (limited to 'swaylock')
-rw-r--r--swaylock/main.c137
-rw-r--r--swaylock/swaylock.1.txt46
2 files changed, 83 insertions, 100 deletions
diff --git a/swaylock/main.c b/swaylock/main.c
index a8d61d88..49b24a3a 100644
--- a/swaylock/main.c
+++ b/swaylock/main.c
@@ -57,7 +57,7 @@ void sway_terminate(int exit_code) {
57 57
58char *password; 58char *password;
59int password_size; 59int password_size;
60int line_source = 0; 60enum line_source line_source = LINE_SOURCE_DEFAULT;
61 61
62struct lock_config *init_config() { 62struct lock_config *init_config() {
63 struct lock_config *config = calloc(1, sizeof(struct lock_config)); 63 struct lock_config *config = calloc(1, sizeof(struct lock_config));
@@ -362,15 +362,15 @@ int main(int argc, char **argv) {
362 {"help", no_argument, NULL, 'h'}, 362 {"help", no_argument, NULL, 'h'},
363 {"color", required_argument, NULL, 'c'}, 363 {"color", required_argument, NULL, 'c'},
364 {"image", required_argument, NULL, 'i'}, 364 {"image", required_argument, NULL, 'i'},
365 {"scaling", required_argument, NULL, 's'}, 365 {"scaling", required_argument, NULL, 0},
366 {"tiling", no_argument, NULL, 't'}, 366 {"tiling", no_argument, NULL, 't'},
367 {"version", no_argument, NULL, 'v'}, 367 {"version", no_argument, NULL, 'v'},
368 {"socket", required_argument, NULL, 'p'}, 368 {"socket", required_argument, NULL, 'p'},
369 {"no-unlock-indicator", no_argument, NULL, 'u'}, 369 {"no-unlock-indicator", no_argument, NULL, 'u'},
370 {"daemonize", no_argument, NULL, 'f'}, 370 {"daemonize", no_argument, NULL, 'f'},
371 {"font", required_argument, NULL, 0}, 371 {"font", required_argument, NULL, 0},
372 {"line-uses-ring", no_argument, NULL, 0}, 372 {"line-uses-ring", no_argument, NULL, 'r'},
373 {"line-uses-inside", no_argument, NULL, 0}, 373 {"line-uses-inside", no_argument, NULL, 's'},
374 {"textcolor", required_argument, NULL, 0}, 374 {"textcolor", required_argument, NULL, 0},
375 {"insidevercolor", required_argument, NULL, 0}, 375 {"insidevercolor", required_argument, NULL, 0},
376 {"insidewrongcolor", required_argument, NULL, 0}, 376 {"insidewrongcolor", required_argument, NULL, 0},
@@ -388,27 +388,16 @@ int main(int argc, char **argv) {
388 const char *usage = 388 const char *usage =
389 "Usage: swaylock [options...]\n" 389 "Usage: swaylock [options...]\n"
390 "\n" 390 "\n"
391 " -h, --help Show help message and quit.\n" 391 " -h, --help Show help message and quit.\n"
392 " -c, --color <rrggbb[aa]> Turn the screen into the given color instead of white.\n" 392 " -c, --color <rrggbb[aa]> Turn the screen into the given color instead of white.\n"
393 " -s, --scaling Scaling mode: stretch, fill, fit, center, tile.\n" 393 " --scaling Scaling mode: stretch, fill, fit, center, tile.\n"
394 " -t, --tiling Same as --scaling=tile.\n" 394 " -t, --tiling Same as --scaling=tile.\n"
395 " -v, --version Show the version number and quit.\n" 395 " -v, --version Show the version number and quit.\n"
396 " -i, --image [<output>:]<path> Display the given image.\n" 396 " -i, --image [<output>:]<path> Display the given image.\n"
397 " -u, --no-unlock-indicator Disable the unlock indicator.\n" 397 " -u, --no-unlock-indicator Disable the unlock indicator.\n"
398 " -f, --daemonize Detach from the controlling terminal.\n" 398 " -f, --daemonize Detach from the controlling terminal.\n"
399 " --socket <socket> Use the specified socket.\n" 399 " --socket <socket> Use the specified socket.\n"
400 " --font <font> Use the specified font instead of sans-serif.\n" 400 " For more information see `man swaylock`\n";
401 " --textcolor <rrggbb[aa]> Sets the color of the text.\n"
402 " --insidevercolor <rrggbb[aa]> Sets the color of the verifying indicator circle.\n"
403 " --insidewrongcolor <rrggbb[aa]> Sets the color of the invalid indicator circle.\n"
404 " --insidecolor <rrggbb[aa]> Sets the color of the typing or idle indicator circle.\n"
405 " --ringvercolor <rrggbb[aa]> Sets the color of the verifying indicator ring.\n"
406 " --ringwrongcolor <rrggbb[aa]> Sets the color of the invalid indicator ring.\n"
407 " --ringcolor <rrggbb[aa]> Sets the color of the typing or idle indicator ring.\n"
408 " --linecolor <rrggbb[aa]> Sets the color of the line that separates the indicator.\n"
409 " --separatorcolor <rrggbb[aa]> Sets the color of the line that separates highlight segments.\n"
410 " --keyhlcolor <rrggbb[aa]> Sets the color of keypress highlight segments.\n"
411 " --bshlcolor <rrggbb[aa]> Sets the color of keypress highlight segments.\n";
412 401
413 402
414 registry = registry_poll(); 403 registry = registry_poll();
@@ -416,7 +405,7 @@ int main(int argc, char **argv) {
416 int c; 405 int c;
417 while (1) { 406 while (1) {
418 int option_index = 0; 407 int option_index = 0;
419 c = getopt_long(argc, argv, "hc:i:s:tvuf", long_options, &option_index); 408 c = getopt_long(argc, argv, "hc:i:srtvuf", long_options, &option_index);
420 if (c == -1) { 409 if (c == -1) {
421 break; 410 break;
422 } 411 }
@@ -454,9 +443,6 @@ int main(int argc, char **argv) {
454 } 443 }
455 break; 444 break;
456 } 445 }
457 case 's':
458 scaling_mode_str = optarg;
459 break;
460 case 't': 446 case 't':
461 scaling_mode_str = "tile"; 447 scaling_mode_str = "tile";
462 break; 448 break;
@@ -480,56 +466,47 @@ int main(int argc, char **argv) {
480 exit(EXIT_FAILURE); 466 exit(EXIT_FAILURE);
481 } 467 }
482 break; 468 break;
469 case 'r':
470 if (line_source != LINE_SOURCE_DEFAULT) {
471 sway_log(L_ERROR, "line source options conflict");
472 exit(EXIT_FAILURE);
473 }
474 line_source = LINE_SOURCE_RING;
475 break;
476 case 's':
477 if (line_source != LINE_SOURCE_DEFAULT) {
478 sway_log(L_ERROR, "line source options conflict");
479 exit(EXIT_FAILURE);
480 }
481 line_source = LINE_SOURCE_INSIDE;
482 break;
483 case 0: 483 case 0:
484 if (strcmp(long_options[option_index].name, "font") == 0) { 484 if (strcmp(long_options[option_index].name, "font") == 0) {
485 free(config->font); 485 free(config->font);
486 config->font = strdup(optarg); 486 config->font = strdup(optarg);
487 } 487 } else if (strcmp(long_options[option_index].name, "scaling") == 0) {
488 else if (strcmp(long_options[option_index].name, "line-uses-ring") == 0) { 488 scaling_mode_str = optarg;
489 if (line_source != 0) { 489 } else if (strcmp(long_options[option_index].name, "textcolor") == 0) {
490 sway_log(L_ERROR, "Line source options conflict");
491 exit(EXIT_FAILURE);
492 }
493 line_source = 1;
494 }
495 else if (strcmp(long_options[option_index].name, "line-uses-inside") == 0) {
496 if (line_source != 0) {
497 sway_log(L_ERROR, "Line source options conflict");
498 exit(EXIT_FAILURE);
499 }
500 line_source = 2;
501 }
502 else if (strcmp(long_options[option_index].name, "textcolor") == 0) {
503 config->colors.text = parse_color(optarg); 490 config->colors.text = parse_color(optarg);
504 } 491 } else if (strcmp(long_options[option_index].name, "insidevercolor") == 0) {
505 else if (strcmp(long_options[option_index].name, "insidevercolor") == 0) {
506 config->colors.validating.inner_ring = parse_color(optarg); 492 config->colors.validating.inner_ring = parse_color(optarg);
507 } 493 } else if (strcmp(long_options[option_index].name, "insidewrongcolor") == 0) {
508 else if (strcmp(long_options[option_index].name, "insidewrongcolor") == 0) {
509 config->colors.invalid.inner_ring = parse_color(optarg); 494 config->colors.invalid.inner_ring = parse_color(optarg);
510 } 495 } else if (strcmp(long_options[option_index].name, "insidecolor") == 0) {
511 else if (strcmp(long_options[option_index].name, "insidecolor") == 0) {
512 config->colors.normal.inner_ring = parse_color(optarg); 496 config->colors.normal.inner_ring = parse_color(optarg);
513 } 497 } else if (strcmp(long_options[option_index].name, "ringvercolor") == 0) {
514 else if (strcmp(long_options[option_index].name, "ringvercolor") == 0) {
515 config->colors.validating.outer_ring = parse_color(optarg); 498 config->colors.validating.outer_ring = parse_color(optarg);
516 } 499 } else if (strcmp(long_options[option_index].name, "ringwrongcolor") == 0) {
517 else if (strcmp(long_options[option_index].name, "ringwrongcolor") == 0) {
518 config->colors.invalid.outer_ring = parse_color(optarg); 500 config->colors.invalid.outer_ring = parse_color(optarg);
519 } 501 } else if (strcmp(long_options[option_index].name, "ringcolor") == 0) {
520 else if (strcmp(long_options[option_index].name, "ringcolor") == 0) {
521 config->colors.normal.outer_ring = parse_color(optarg); 502 config->colors.normal.outer_ring = parse_color(optarg);
522 } 503 } else if (strcmp(long_options[option_index].name, "linecolor") == 0) {
523 else if (strcmp(long_options[option_index].name, "linecolor") == 0) {
524 config->colors.line = parse_color(optarg); 504 config->colors.line = parse_color(optarg);
525 } 505 } else if (strcmp(long_options[option_index].name, "separatorcolor") == 0) {
526 else if (strcmp(long_options[option_index].name, "separatorcolor") == 0) {
527 config->colors.separator = parse_color(optarg); 506 config->colors.separator = parse_color(optarg);
528 } 507 } else if (strcmp(long_options[option_index].name, "keyhlcolor") == 0) {
529 else if (strcmp(long_options[option_index].name, "keyhlcolor") == 0) {
530 config->colors.input_cursor = parse_color(optarg); 508 config->colors.input_cursor = parse_color(optarg);
531 } 509 } else if (strcmp(long_options[option_index].name, "bshlcolor") == 0) {
532 else if (strcmp(long_options[option_index].name, "bshlcolor") == 0) {
533 config->colors.backspace_cursor = parse_color(optarg); 510 config->colors.backspace_cursor = parse_color(optarg);
534 } 511 }
535 break; 512 break;
@@ -783,39 +760,35 @@ void render(struct render_data *render_data, struct lock_config *config) {
783 cairo_stroke(window->cairo); 760 cairo_stroke(window->cairo);
784 } 761 }
785 762
786 if (line_source == 1) { 763 switch(line_source) {
764 case LINE_SOURCE_RING:
787 switch(render_data->auth_state) { 765 switch(render_data->auth_state) {
788 case AUTH_STATE_VALIDATING: { 766 case AUTH_STATE_VALIDATING:
789 cairo_set_source_u32(window->cairo, config->colors.validating.outer_ring); 767 cairo_set_source_u32(window->cairo, config->colors.validating.outer_ring);
790 break; 768 break;
791 } 769 case AUTH_STATE_INVALID:
792 case AUTH_STATE_INVALID: {
793 cairo_set_source_u32(window->cairo, config->colors.invalid.outer_ring); 770 cairo_set_source_u32(window->cairo, config->colors.invalid.outer_ring);
794 break; 771 break;
795 } 772 default:
796 default: {
797 cairo_set_source_u32(window->cairo, config->colors.normal.outer_ring); 773 cairo_set_source_u32(window->cairo, config->colors.normal.outer_ring);
798 } 774 }
799 } 775 break;
800 } 776 case LINE_SOURCE_INSIDE:
801 else if (line_source == 2) {
802 switch(render_data->auth_state) { 777 switch(render_data->auth_state) {
803 case AUTH_STATE_VALIDATING: { 778 case AUTH_STATE_VALIDATING:
804 cairo_set_source_u32(window->cairo, config->colors.validating.inner_ring); 779 cairo_set_source_u32(window->cairo, config->colors.validating.inner_ring);
805 break; 780 break;
806 } 781 case AUTH_STATE_INVALID:
807 case AUTH_STATE_INVALID: {
808 cairo_set_source_u32(window->cairo, config->colors.invalid.inner_ring); 782 cairo_set_source_u32(window->cairo, config->colors.invalid.inner_ring);
809 break; 783 break;
810 } 784 default:
811 default: {
812 cairo_set_source_u32(window->cairo, config->colors.normal.inner_ring); 785 cairo_set_source_u32(window->cairo, config->colors.normal.inner_ring);
813 break; 786 break;
814 } 787 }
815 } 788 break;
816 } 789 default:
817 else {
818 cairo_set_source_u32(window->cairo, config->colors.line); 790 cairo_set_source_u32(window->cairo, config->colors.line);
791 break;
819 } 792 }
820 // Draw inner + outer border of the circle 793 // Draw inner + outer border of the circle
821 cairo_set_line_width(window->cairo, 2.0); 794 cairo_set_line_width(window->cairo, 2.0);
diff --git a/swaylock/swaylock.1.txt b/swaylock/swaylock.1.txt
index 9c6c3e10..c5e3dcf7 100644
--- a/swaylock/swaylock.1.txt
+++ b/swaylock/swaylock.1.txt
@@ -29,7 +29,7 @@ Options
29*-i, \--image* [<output>:]<path>:: 29*-i, \--image* [<output>:]<path>::
30 Display the given image, optionally only on the given output. 30 Display the given image, optionally only on the given output.
31 31
32*-s, \--scaling*:: 32*--scaling*::
33 Scaling mode for images: stretch, fill, fit, center, or tile. 33 Scaling mode for images: stretch, fill, fit, center, or tile.
34 34
35*-t, --tiling*:: 35*-t, --tiling*::
@@ -45,11 +45,17 @@ Options
45 Use the specified socket path. Otherwise, swaymsg will ask sway where the 45 Use the specified socket path. Otherwise, swaymsg will ask sway where the
46 socket is (which is the value of $SWAYSOCK, then of $I3SOCK). 46 socket is (which is the value of $SWAYSOCK, then of $I3SOCK).
47 47
48Appearance
49----------
50
51*--bshlcolor* <rrggbb[aa]>::
52 Sets the color of backspace highlight segments.
53
48*--font* <font>:: 54*--font* <font>::
49 Sets the font of the text inside the indicator. 55 Sets the font of the text inside the indicator.
50 56
51*--textcolor* <rrggbb[aa]>:: 57*--insidecolor* <rrggbb[aa]>::
52 Sets the color of the text inside the indicator. 58 Sets the color of the inside of the indicator when typing or idle.
53 59
54*--insidevercolor* <rrggbb[aa]>:: 60*--insidevercolor* <rrggbb[aa]>::
55 Sets the color of the inside of the indicator when verifying. 61 Sets the color of the inside of the indicator when verifying.
@@ -57,31 +63,35 @@ Options
57*--insidewrongcolor* <rrggbb[aa]>:: 63*--insidewrongcolor* <rrggbb[aa]>::
58 Sets the color of the inside of the indicator when invalid. 64 Sets the color of the inside of the indicator when invalid.
59 65
60*--insidecolor* <rrggbb[aa]>:: 66*--keyhlcolor* <rrggbb[aa]>::
61 Sets the color of the inside of the indicator when typing or idle. 67 Sets the color of keypress highlight segments.
62 68
63*--ringvercolor* <rrggbb[aa]>:: 69*--linecolor* <rrggbb[aa]>::
64 Sets the color of the outside of the indicator when verifying. 70 Sets the color of the lines that separate the inside and outside of the
71 indicator.
65 72
66*--ringwrongcolor* <rrggbb[aa]>:: 73*-s, \--line-uses-inside*::
67 Sets the color of the outside of the indicator when invalid. 74 Use the color of the inside of the indicator for the line separating the
75 inside and outside of the indicator.
76
77*-r, \--line-uses-ring*::
78 Use the outer ring's color for the line separating the inside and outside of
79 the indicator.
68 80
69*--ringcolor* <rrggbb[aa]>:: 81*--ringcolor* <rrggbb[aa]>::
70 Sets the color of the outside of the indicator when typing or idle. 82 Sets the color of the outside of the indicator when typing or idle.
71 83
72*--linecolor* <rrggbb[aa]>:: 84*--ringvercolor* <rrggbb[aa]>::
73 Sets the color of the lines that separate the inside and outside of the 85 Sets the color of the outside of the indicator when verifying.
74 indicator. 86
87*--ringwrongcolor* <rrggbb[aa]>::
88 Sets the color of the outside of the indicator when invalid.
75 89
76*--separatorcolor* <rrggbb[aa]>:: 90*--separatorcolor* <rrggbb[aa]>::
77 Sets the color of the lines that seperate highlight segments. 91 Sets the color of the lines that seperate highlight segments.
78 92
79*--keyhlcolor* <rrggbb[aa]>:: 93*--textcolor* <rrggbb[aa]>::
80 Sets the color of keypress highlight segments. 94 Sets the color of the text inside the indicator.
81
82*--bshlcolor* <rrggbb[aa]>::
83 Sets the color of backspace highlight segments.
84
85 95
86Authors 96Authors
87------- 97-------