aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/swaylock/swaylock.h5
-rw-r--r--swaylock/main.c153
-rw-r--r--swaylock/render.c27
-rw-r--r--swaylock/swaylock.1.scd25
4 files changed, 171 insertions, 39 deletions
diff --git a/include/swaylock/swaylock.h b/include/swaylock/swaylock.h
index 18af7ab4..516a56f4 100644
--- a/include/swaylock/swaylock.h
+++ b/include/swaylock/swaylock.h
@@ -22,6 +22,7 @@ enum auth_state {
22struct swaylock_colorset { 22struct swaylock_colorset {
23 uint32_t input; 23 uint32_t input;
24 uint32_t cleared; 24 uint32_t cleared;
25 uint32_t caps_lock;
25 uint32_t verifying; 26 uint32_t verifying;
26 uint32_t wrong; 27 uint32_t wrong;
27}; 28};
@@ -30,6 +31,8 @@ struct swaylock_colors {
30 uint32_t background; 31 uint32_t background;
31 uint32_t bs_highlight; 32 uint32_t bs_highlight;
32 uint32_t key_highlight; 33 uint32_t key_highlight;
34 uint32_t caps_lock_bs_highlight;
35 uint32_t caps_lock_key_highlight;
33 uint32_t separator; 36 uint32_t separator;
34 struct swaylock_colorset inside; 37 struct swaylock_colorset inside;
35 struct swaylock_colorset line; 38 struct swaylock_colorset line;
@@ -45,6 +48,8 @@ struct swaylock_args {
45 uint32_t thickness; 48 uint32_t thickness;
46 bool ignore_empty; 49 bool ignore_empty;
47 bool show_indicator; 50 bool show_indicator;
51 bool show_caps_lock_text;
52 bool show_caps_lock_indicator;
48 bool daemonize; 53 bool daemonize;
49}; 54};
50 55
diff --git a/swaylock/main.c b/swaylock/main.c
index 9a4f3b58..0b167da1 100644
--- a/swaylock/main.c
+++ b/swaylock/main.c
@@ -396,28 +396,34 @@ static void set_default_colors(struct swaylock_colors *colors) {
396 colors->background = 0xFFFFFFFF; 396 colors->background = 0xFFFFFFFF;
397 colors->bs_highlight = 0xDB3300FF; 397 colors->bs_highlight = 0xDB3300FF;
398 colors->key_highlight = 0x33DB00FF; 398 colors->key_highlight = 0x33DB00FF;
399 colors->caps_lock_bs_highlight = 0xDB3300FF;
400 colors->caps_lock_key_highlight = 0x33DB00FF;
399 colors->separator = 0x000000FF; 401 colors->separator = 0x000000FF;
400 colors->inside = (struct swaylock_colorset){ 402 colors->inside = (struct swaylock_colorset){
401 .input = 0x000000C0, 403 .input = 0x000000C0,
402 .cleared = 0xE5A445C0, 404 .cleared = 0xE5A445C0,
405 .caps_lock = 0x000000C0,
403 .verifying = 0x0072FFC0, 406 .verifying = 0x0072FFC0,
404 .wrong = 0xFA0000C0, 407 .wrong = 0xFA0000C0,
405 }; 408 };
406 colors->line = (struct swaylock_colorset){ 409 colors->line = (struct swaylock_colorset){
407 .input = 0x000000FF, 410 .input = 0x000000FF,
408 .cleared = 0x000000FF, 411 .cleared = 0x000000FF,
412 .caps_lock = 0x000000FF,
409 .verifying = 0x000000FF, 413 .verifying = 0x000000FF,
410 .wrong = 0x000000FF, 414 .wrong = 0x000000FF,
411 }; 415 };
412 colors->ring = (struct swaylock_colorset){ 416 colors->ring = (struct swaylock_colorset){
413 .input = 0x337D00FF, 417 .input = 0x337D00FF,
414 .cleared = 0xE5A445FF, 418 .cleared = 0xE5A445FF,
419 .caps_lock = 0xE5A445FF,
415 .verifying = 0x3300FFFF, 420 .verifying = 0x3300FFFF,
416 .wrong = 0x7D3300FF, 421 .wrong = 0x7D3300FF,
417 }; 422 };
418 colors->text = (struct swaylock_colorset){ 423 colors->text = (struct swaylock_colorset){
419 .input = 0xE5A445FF, 424 .input = 0xE5A445FF,
420 .cleared = 0x000000FF, 425 .cleared = 0x000000FF,
426 .caps_lock = 0xE5A445FF,
421 .verifying = 0x000000FF, 427 .verifying = 0x000000FF,
422 .wrong = 0x000000FF, 428 .wrong = 0x000000FF,
423 }; 429 };
@@ -433,25 +439,31 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
433 enum line_mode *line_mode, char **config_path) { 439 enum line_mode *line_mode, char **config_path) {
434 enum long_option_codes { 440 enum long_option_codes {
435 LO_BS_HL_COLOR = 256, 441 LO_BS_HL_COLOR = 256,
442 LO_CAPS_LOCK_BS_HL_COLOR,
443 LO_CAPS_LOCK_KEY_HL_COLOR,
436 LO_FONT, 444 LO_FONT,
437 LO_IND_RADIUS, 445 LO_IND_RADIUS,
438 LO_IND_THICKNESS, 446 LO_IND_THICKNESS,
439 LO_INSIDE_COLOR, 447 LO_INSIDE_COLOR,
440 LO_INSIDE_CLEAR_COLOR, 448 LO_INSIDE_CLEAR_COLOR,
449 LO_INSIDE_CAPS_LOCK_COLOR,
441 LO_INSIDE_VER_COLOR, 450 LO_INSIDE_VER_COLOR,
442 LO_INSIDE_WRONG_COLOR, 451 LO_INSIDE_WRONG_COLOR,
443 LO_KEY_HL_COLOR, 452 LO_KEY_HL_COLOR,
444 LO_LINE_COLOR, 453 LO_LINE_COLOR,
445 LO_LINE_CLEAR_COLOR, 454 LO_LINE_CLEAR_COLOR,
455 LO_LINE_CAPS_LOCK_COLOR,
446 LO_LINE_VER_COLOR, 456 LO_LINE_VER_COLOR,
447 LO_LINE_WRONG_COLOR, 457 LO_LINE_WRONG_COLOR,
448 LO_RING_COLOR, 458 LO_RING_COLOR,
449 LO_RING_CLEAR_COLOR, 459 LO_RING_CLEAR_COLOR,
460 LO_RING_CAPS_LOCK_COLOR,
450 LO_RING_VER_COLOR, 461 LO_RING_VER_COLOR,
451 LO_RING_WRONG_COLOR, 462 LO_RING_WRONG_COLOR,
452 LO_SEP_COLOR, 463 LO_SEP_COLOR,
453 LO_TEXT_COLOR, 464 LO_TEXT_COLOR,
454 LO_TEXT_CLEAR_COLOR, 465 LO_TEXT_CLEAR_COLOR,
466 LO_TEXT_CAPS_LOCK_COLOR,
455 LO_TEXT_VER_COLOR, 467 LO_TEXT_VER_COLOR,
456 LO_TEXT_WRONG_COLOR, 468 LO_TEXT_WRONG_COLOR,
457 }; 469 };
@@ -463,6 +475,8 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
463 {"daemonize", no_argument, NULL, 'f'}, 475 {"daemonize", no_argument, NULL, 'f'},
464 {"help", no_argument, NULL, 'h'}, 476 {"help", no_argument, NULL, 'h'},
465 {"image", required_argument, NULL, 'i'}, 477 {"image", required_argument, NULL, 'i'},
478 {"disable-caps-lock-text", no_argument, NULL, 'L'},
479 {"indicator-caps-lock", no_argument, NULL, 'l'},
466 {"line-uses-inside", no_argument, NULL, 'n'}, 480 {"line-uses-inside", no_argument, NULL, 'n'},
467 {"socket", required_argument, NULL, 'p'}, 481 {"socket", required_argument, NULL, 'p'},
468 {"line-uses-ring", no_argument, NULL, 'r'}, 482 {"line-uses-ring", no_argument, NULL, 'r'},
@@ -471,25 +485,31 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
471 {"no-unlock-indicator", no_argument, NULL, 'u'}, 485 {"no-unlock-indicator", no_argument, NULL, 'u'},
472 {"version", no_argument, NULL, 'v'}, 486 {"version", no_argument, NULL, 'v'},
473 {"bs-hl-color", required_argument, NULL, LO_BS_HL_COLOR}, 487 {"bs-hl-color", required_argument, NULL, LO_BS_HL_COLOR},
488 {"caps-lock-bs-hl-color", required_argument, NULL, LO_CAPS_LOCK_BS_HL_COLOR},
489 {"caps-lock-key-hl-color", required_argument, NULL, LO_CAPS_LOCK_KEY_HL_COLOR},
474 {"font", required_argument, NULL, LO_FONT}, 490 {"font", required_argument, NULL, LO_FONT},
475 {"indicator-radius", required_argument, NULL, LO_IND_RADIUS}, 491 {"indicator-radius", required_argument, NULL, LO_IND_RADIUS},
476 {"indicator-thickness", required_argument, NULL, LO_IND_THICKNESS}, 492 {"indicator-thickness", required_argument, NULL, LO_IND_THICKNESS},
477 {"inside-color", required_argument, NULL, LO_INSIDE_COLOR}, 493 {"inside-color", required_argument, NULL, LO_INSIDE_COLOR},
478 {"inside-clear-color", required_argument, NULL, LO_INSIDE_CLEAR_COLOR}, 494 {"inside-clear-color", required_argument, NULL, LO_INSIDE_CLEAR_COLOR},
495 {"inside-caps-lock-color", required_argument, NULL, LO_INSIDE_CAPS_LOCK_COLOR},
479 {"inside-ver-color", required_argument, NULL, LO_INSIDE_VER_COLOR}, 496 {"inside-ver-color", required_argument, NULL, LO_INSIDE_VER_COLOR},
480 {"inside-wrong-color", required_argument, NULL, LO_INSIDE_WRONG_COLOR}, 497 {"inside-wrong-color", required_argument, NULL, LO_INSIDE_WRONG_COLOR},
481 {"key-hl-color", required_argument, NULL, LO_KEY_HL_COLOR}, 498 {"key-hl-color", required_argument, NULL, LO_KEY_HL_COLOR},
482 {"line-color", required_argument, NULL, LO_LINE_COLOR}, 499 {"line-color", required_argument, NULL, LO_LINE_COLOR},
483 {"line-clear-color", required_argument, NULL, LO_LINE_CLEAR_COLOR}, 500 {"line-clear-color", required_argument, NULL, LO_LINE_CLEAR_COLOR},
501 {"line-caps-lock-color", required_argument, NULL, LO_LINE_CAPS_LOCK_COLOR},
484 {"line-ver-color", required_argument, NULL, LO_LINE_VER_COLOR}, 502 {"line-ver-color", required_argument, NULL, LO_LINE_VER_COLOR},
485 {"line-wrong-color", required_argument, NULL, LO_LINE_WRONG_COLOR}, 503 {"line-wrong-color", required_argument, NULL, LO_LINE_WRONG_COLOR},
486 {"ring-color", required_argument, NULL, LO_RING_COLOR}, 504 {"ring-color", required_argument, NULL, LO_RING_COLOR},
487 {"ring-clear-color", required_argument, NULL, LO_RING_CLEAR_COLOR}, 505 {"ring-clear-color", required_argument, NULL, LO_RING_CLEAR_COLOR},
506 {"ring-caps-lock-color", required_argument, NULL, LO_RING_CAPS_LOCK_COLOR},
488 {"ring-ver-color", required_argument, NULL, LO_RING_VER_COLOR}, 507 {"ring-ver-color", required_argument, NULL, LO_RING_VER_COLOR},
489 {"ring-wrong-color", required_argument, NULL, LO_RING_WRONG_COLOR}, 508 {"ring-wrong-color", required_argument, NULL, LO_RING_WRONG_COLOR},
490 {"separator-color", required_argument, NULL, LO_SEP_COLOR}, 509 {"separator-color", required_argument, NULL, LO_SEP_COLOR},
491 {"text-color", required_argument, NULL, LO_TEXT_COLOR}, 510 {"text-color", required_argument, NULL, LO_TEXT_COLOR},
492 {"text-clear-color", required_argument, NULL, LO_TEXT_CLEAR_COLOR}, 511 {"text-clear-color", required_argument, NULL, LO_TEXT_CLEAR_COLOR},
512 {"text-caps-lock-color", required_argument, NULL, LO_TEXT_CAPS_LOCK_COLOR},
493 {"text-ver-color", required_argument, NULL, LO_TEXT_VER_COLOR}, 513 {"text-ver-color", required_argument, NULL, LO_TEXT_VER_COLOR},
494 {"text-wrong-color", required_argument, NULL, LO_TEXT_WRONG_COLOR}, 514 {"text-wrong-color", required_argument, NULL, LO_TEXT_WRONG_COLOR},
495 {0, 0, 0, 0} 515 {0, 0, 0, 0}
@@ -498,76 +518,97 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
498 const char usage[] = 518 const char usage[] =
499 "Usage: swaylock [options...]\n" 519 "Usage: swaylock [options...]\n"
500 "\n" 520 "\n"
501 " -C, --config <config_file> " 521 " -C, --config <config_file> "
502 "Path to the config file.\n" 522 "Path to the config file.\n"
503 " -c, --color <color> " 523 " -c, --color <color> "
504 "Turn the screen into the given color instead of white.\n" 524 "Turn the screen into the given color instead of white.\n"
505 " -e, --ignore-empty-password " 525 " -e, --ignore-empty-password "
506 "When an empty password is provided, do not validate it.\n" 526 "When an empty password is provided, do not validate it.\n"
507 " -f, --daemonize " 527 " -f, --daemonize "
508 "Detach from the controlling terminal after locking.\n" 528 "Detach from the controlling terminal after locking.\n"
509 " -h, --help " 529 " -h, --help "
510 "Show help message and quit.\n" 530 "Show help message and quit.\n"
511 " -i, --image [<output>:]<path> " 531 " -i, --image [<output>:]<path> "
512 "Display the given image.\n" 532 "Display the given image.\n"
513 " -s, --scaling <mode> " 533 " -L, --disable-caps-lock-text "
534 "Disable the Caps Lock text.\n"
535 " -l, --indicator-caps-lock "
536 "Show the current Caps Lock state also on the indicator.\n"
537 " -s, --scaling <mode> "
514 "Scaling mode: stretch, fill, fit, center, tile.\n" 538 "Scaling mode: stretch, fill, fit, center, tile.\n"
515 " -t, --tiling " 539 " -t, --tiling "
516 "Same as --scaling=tile.\n" 540 "Same as --scaling=tile.\n"
517 " -u, --no-unlock-indicator " 541 " -u, --no-unlock-indicator "
518 "Disable the unlock indicator.\n" 542 "Disable the unlock indicator.\n"
519 " -v, --version " 543 " -v, --version "
520 "Show the version number and quit.\n" 544 "Show the version number and quit.\n"
521 " --bs-hl-color <color> " 545 " --bs-hl-color <color> "
522 "Sets the color of backspace highlight segments.\n" 546 "Sets the color of backspace highlight segments.\n"
523 " --font <font> " 547 " --caps-lock-bs-hl-color <color> "
548 "Sets the color of backspace highlight segments when Caps Lock "
549 "is active.\n"
550 " --caps-lock-key-hl-color <color> "
551 "Sets the color of the key press highlight segments when "
552 "Caps Lock is active.\n"
553 " --font <font> "
524 "Sets the font of the text.\n" 554 "Sets the font of the text.\n"
525 " --indicator-radius <radius> " 555 " --indicator-radius <radius> "
526 "Sets the indicator radius.\n" 556 "Sets the indicator radius.\n"
527 " --indicator-thickness <thick> " 557 " --indicator-thickness <thick> "
528 "Sets the indicator thickness.\n" 558 "Sets the indicator thickness.\n"
529 " --inside-color <color> " 559 " --inside-color <color> "
530 "Sets the color of the inside of the indicator.\n" 560 "Sets the color of the inside of the indicator.\n"
531 " --inside-clear-color <color> " 561 " --inside-clear-color <color> "
532 "Sets the color of the inside of the indicator when cleared.\n" 562 "Sets the color of the inside of the indicator when cleared.\n"
533 " --inside-ver-color <color> " 563 " --inside-caps-lock-color <color> "
564 "Sets the color of the inside of the indicator when Caps Lock "
565 "is active.\n"
566 " --inside-ver-color <color> "
534 "Sets the color of the inside of the indicator when verifying.\n" 567 "Sets the color of the inside of the indicator when verifying.\n"
535 " --inside-wrong-color <color> " 568 " --inside-wrong-color <color> "
536 "Sets the color of the inside of the indicator when invalid.\n" 569 "Sets the color of the inside of the indicator when invalid.\n"
537 " --key-hl-color <color> " 570 " --key-hl-color <color> "
538 "Sets the color of the key press highlight segments.\n" 571 "Sets the color of the key press highlight segments.\n"
539 " --line-color <color> " 572 " --line-color <color> "
540 "Sets the color of the line between the inside and ring.\n" 573 "Sets the color of the line between the inside and ring.\n"
541 " --line-clear-color <color> " 574 " --line-clear-color <color> "
542 "Sets the color of the line between the inside and ring when " 575 "Sets the color of the line between the inside and ring when "
543 "cleared.\n" 576 "cleared.\n"
544 " --line-ver-color <color> " 577 " --line-caps-lock-color <color> "
578 "Sets the color of the line between the inside and ring when "
579 "Caps Lock is active.\n"
580 " --line-ver-color <color> "
545 "Sets the color of the line between the inside and ring when " 581 "Sets the color of the line between the inside and ring when "
546 "verifying.\n" 582 "verifying.\n"
547 " --line-wrong-color <color> " 583 " --line-wrong-color <color> "
548 "Sets the color of the line between the inside and ring when " 584 "Sets the color of the line between the inside and ring when "
549 "invalid.\n" 585 "invalid.\n"
550 " -n, --line-uses-inside " 586 " -n, --line-uses-inside "
551 "Use the inside color for the line between the inside and ring.\n" 587 "Use the inside color for the line between the inside and ring.\n"
552 " -r, --line-uses-ring " 588 " -r, --line-uses-ring "
553 "Use the ring color for the line between the inside and ring.\n" 589 "Use the ring color for the line between the inside and ring.\n"
554 " --ring-color <color> " 590 " --ring-color <color> "
555 "Sets the color of the ring of the indicator.\n" 591 "Sets the color of the ring of the indicator.\n"
556 " --ring-clear-color <color> " 592 " --ring-clear-color <color> "
557 "Sets the color of the ring of the indicator when cleared.\n" 593 "Sets the color of the ring of the indicator when cleared.\n"
558 " --ring-ver-color <color> " 594 " --ring-caps-lock-color <color> "
595 "Sets the color of the ring of the indicator when Caps Lock "
596 "is active.\n"
597 " --ring-ver-color <color> "
559 "Sets the color of the ring of the indicator when verifying.\n" 598 "Sets the color of the ring of the indicator when verifying.\n"
560 " --ring-wrong-color <color> " 599 " --ring-wrong-color <color> "
561 "Sets the color of the ring of the indicator when invalid.\n" 600 "Sets the color of the ring of the indicator when invalid.\n"
562 " --separator-color <color> " 601 " --separator-color <color> "
563 "Sets the color of the lines that separate highlight segments.\n" 602 "Sets the color of the lines that separate highlight segments.\n"
564 " --text-color <color> " 603 " --text-color <color> "
565 "Sets the color of the text.\n" 604 "Sets the color of the text.\n"
566 " --text-clear-color <color> " 605 " --text-clear-color <color> "
567 "Sets the color of the text when cleared.\n" 606 "Sets the color of the text when cleared.\n"
568 " --text-ver-color <color> " 607 " --text-caps-lock-color <color> "
608 "Sets the color of the text when Caps Lock is active.\n"
609 " --text-ver-color <color> "
569 "Sets the color of the text when verifying.\n" 610 "Sets the color of the text when verifying.\n"
570 " --text-wrong-color <color> " 611 " --text-wrong-color <color> "
571 "Sets the color of the text when invalid.\n" 612 "Sets the color of the text when invalid.\n"
572 "\n" 613 "\n"
573 "All <color> options are of the form <rrggbb[aa]>.\n"; 614 "All <color> options are of the form <rrggbb[aa]>.\n";
@@ -576,7 +617,7 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
576 optind = 1; 617 optind = 1;
577 while (1) { 618 while (1) {
578 int opt_idx = 0; 619 int opt_idx = 0;
579 c = getopt_long(argc, argv, "c:efhi:nrs:tuvC:", long_options, &opt_idx); 620 c = getopt_long(argc, argv, "c:efhi:Llnrs:tuvC:", long_options, &opt_idx);
580 if (c == -1) { 621 if (c == -1) {
581 break; 622 break;
582 } 623 }
@@ -607,6 +648,16 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
607 load_image(optarg, state); 648 load_image(optarg, state);
608 } 649 }
609 break; 650 break;
651 case 'L':
652 if (state) {
653 state->args.show_caps_lock_text = false;
654 }
655 break;
656 case 'l':
657 if (state) {
658 state->args.show_caps_lock_indicator = true;
659 }
660 break;
610 case 'n': 661 case 'n':
611 if (line_mode) { 662 if (line_mode) {
612 *line_mode = LM_INSIDE; 663 *line_mode = LM_INSIDE;
@@ -644,6 +695,16 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
644 state->args.colors.bs_highlight = parse_color(optarg); 695 state->args.colors.bs_highlight = parse_color(optarg);
645 } 696 }
646 break; 697 break;
698 case LO_CAPS_LOCK_BS_HL_COLOR:
699 if (state) {
700 state->args.colors.caps_lock_bs_highlight = parse_color(optarg);
701 }
702 break;
703 case LO_CAPS_LOCK_KEY_HL_COLOR:
704 if (state) {
705 state->args.colors.caps_lock_key_highlight = parse_color(optarg);
706 }
707 break;
647 case LO_FONT: 708 case LO_FONT:
648 if (state) { 709 if (state) {
649 free(state->args.font); 710 free(state->args.font);
@@ -670,6 +731,11 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
670 state->args.colors.inside.cleared = parse_color(optarg); 731 state->args.colors.inside.cleared = parse_color(optarg);
671 } 732 }
672 break; 733 break;
734 case LO_INSIDE_CAPS_LOCK_COLOR:
735 if (state) {
736 state->args.colors.inside.caps_lock = parse_color(optarg);
737 }
738 break;
673 case LO_INSIDE_VER_COLOR: 739 case LO_INSIDE_VER_COLOR:
674 if (state) { 740 if (state) {
675 state->args.colors.inside.verifying = parse_color(optarg); 741 state->args.colors.inside.verifying = parse_color(optarg);
@@ -695,6 +761,11 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
695 state->args.colors.line.cleared = parse_color(optarg); 761 state->args.colors.line.cleared = parse_color(optarg);
696 } 762 }
697 break; 763 break;
764 case LO_LINE_CAPS_LOCK_COLOR:
765 if (state) {
766 state->args.colors.line.caps_lock = parse_color(optarg);
767 }
768 break;
698 case LO_LINE_VER_COLOR: 769 case LO_LINE_VER_COLOR:
699 if (state) { 770 if (state) {
700 state->args.colors.line.verifying = parse_color(optarg); 771 state->args.colors.line.verifying = parse_color(optarg);
@@ -715,6 +786,11 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
715 state->args.colors.ring.cleared = parse_color(optarg); 786 state->args.colors.ring.cleared = parse_color(optarg);
716 } 787 }
717 break; 788 break;
789 case LO_RING_CAPS_LOCK_COLOR:
790 if (state) {
791 state->args.colors.ring.caps_lock = parse_color(optarg);
792 }
793 break;
718 case LO_RING_VER_COLOR: 794 case LO_RING_VER_COLOR:
719 if (state) { 795 if (state) {
720 state->args.colors.ring.verifying = parse_color(optarg); 796 state->args.colors.ring.verifying = parse_color(optarg);
@@ -740,6 +816,11 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
740 state->args.colors.text.cleared = parse_color(optarg); 816 state->args.colors.text.cleared = parse_color(optarg);
741 } 817 }
742 break; 818 break;
819 case LO_TEXT_CAPS_LOCK_COLOR:
820 if (state) {
821 state->args.colors.text.caps_lock = parse_color(optarg);
822 }
823 break;
743 case LO_TEXT_VER_COLOR: 824 case LO_TEXT_VER_COLOR:
744 if (state) { 825 if (state) {
745 state->args.colors.text.verifying = parse_color(optarg); 826 state->args.colors.text.verifying = parse_color(optarg);
@@ -857,6 +938,8 @@ int main(int argc, char **argv) {
857 .thickness = 10, 938 .thickness = 10,
858 .ignore_empty = false, 939 .ignore_empty = false,
859 .show_indicator = true, 940 .show_indicator = true,
941 .show_caps_lock_indicator = false,
942 .show_caps_lock_text = true
860 }; 943 };
861 wl_list_init(&state.images); 944 wl_list_init(&state.images);
862 set_default_colors(&state.args.colors); 945 set_default_colors(&state.args.colors);
diff --git a/swaylock/render.c b/swaylock/render.c
index cbd5d01d..5aedaad5 100644
--- a/swaylock/render.c
+++ b/swaylock/render.c
@@ -18,7 +18,17 @@ static void set_color_for_state(cairo_t *cairo, struct swaylock_state *state,
18 } else if (state->auth_state == AUTH_STATE_CLEAR) { 18 } else if (state->auth_state == AUTH_STATE_CLEAR) {
19 cairo_set_source_u32(cairo, colorset->cleared); 19 cairo_set_source_u32(cairo, colorset->cleared);
20 } else { 20 } else {
21 cairo_set_source_u32(cairo, colorset->input); 21 if (state->xkb.caps_lock && state->args.show_caps_lock_indicator) {
22 cairo_set_source_u32(cairo, colorset->caps_lock);
23 } else if (state->xkb.caps_lock && !state->args.show_caps_lock_indicator &&
24 state->args.show_caps_lock_text) {
25 uint32_t inputtextcolor = state->args.colors.text.input;
26 state->args.colors.text.input = state->args.colors.text.caps_lock;
27 cairo_set_source_u32(cairo, colorset->input);
28 state->args.colors.text.input = inputtextcolor;
29 } else {
30 cairo_set_source_u32(cairo, colorset->input);
31 }
22 } 32 }
23} 33}
24 34
@@ -92,7 +102,8 @@ void render_frame(struct swaylock_surface *surface) {
92 break; 102 break;
93 case AUTH_STATE_INPUT: 103 case AUTH_STATE_INPUT:
94 case AUTH_STATE_INPUT_NOP: 104 case AUTH_STATE_INPUT_NOP:
95 if (state->xkb.caps_lock) { 105 case AUTH_STATE_BACKSPACE:
106 if (state->xkb.caps_lock && state->args.show_caps_lock_text) {
96 text = "Caps Lock"; 107 text = "Caps Lock";
97 } 108 }
98 break; 109 break;
@@ -125,9 +136,17 @@ void render_frame(struct swaylock_surface *surface) {
125 arc_radius, highlight_start, 136 arc_radius, highlight_start,
126 highlight_start + TYPE_INDICATOR_RANGE); 137 highlight_start + TYPE_INDICATOR_RANGE);
127 if (state->auth_state == AUTH_STATE_INPUT) { 138 if (state->auth_state == AUTH_STATE_INPUT) {
128 cairo_set_source_u32(cairo, state->args.colors.key_highlight); 139 if (state->xkb.caps_lock && state->args.show_caps_lock_indicator) {
140 cairo_set_source_u32(cairo, state->args.colors.caps_lock_key_highlight);
141 } else {
142 cairo_set_source_u32(cairo, state->args.colors.key_highlight);
143 }
129 } else { 144 } else {
130 cairo_set_source_u32(cairo, state->args.colors.bs_highlight); 145 if (state->xkb.caps_lock && state->args.show_caps_lock_indicator) {
146 cairo_set_source_u32(cairo, state->args.colors.caps_lock_bs_highlight);
147 } else {
148 cairo_set_source_u32(cairo, state->args.colors.bs_highlight);
149 }
131 } 150 }
132 cairo_stroke(cairo); 151 cairo_stroke(cairo);
133 152
diff --git a/swaylock/swaylock.1.scd b/swaylock/swaylock.1.scd
index 9f39a913..2c7979be 100644
--- a/swaylock/swaylock.1.scd
+++ b/swaylock/swaylock.1.scd
@@ -44,6 +44,12 @@ Locks your Wayland session.
44 Display the given image, optionally only on the given output. Use -c to set 44 Display the given image, optionally only on the given output. Use -c to set
45 a background color. 45 a background color.
46 46
47*-L, --disable-caps-lock-text*
48 Disable the Caps Lock Text.
49
50*-l, --indicator-caps-lock*
51 Show the current Caps Lock state also on the indicator.
52
47*-s, --scaling* 53*-s, --scaling*
48 Scaling mode for images: _stretch_, _fill_, _fit_, _center_, or _tile_. 54 Scaling mode for images: _stretch_, _fill_, _fit_, _center_, or _tile_.
49 55
@@ -58,6 +64,12 @@ Locks your Wayland session.
58*--bs-hl-color* <rrggbb[aa]> 64*--bs-hl-color* <rrggbb[aa]>
59 Sets the color of backspace highlight segments. 65 Sets the color of backspace highlight segments.
60 66
67*--caps-lock-bs-hl-color* <rrggbb[aa]>
68 Sets the color of backspace highlight segments when Caps Lock is active.
69
70*--caps-lock-bs-hl-color* <rrggbb[aa]>
71 Sets the color of the key press highlight segments when Caps Lock is active.
72
61*--font* <font> 73*--font* <font>
62 Sets the font of the text inside the indicator. 74 Sets the font of the text inside the indicator.
63 75
@@ -75,6 +87,9 @@ Locks your Wayland session.
75*--inside-clear-color* <rrggbb[aa]> 87*--inside-clear-color* <rrggbb[aa]>
76 Sets the color of the inside of the indicator when cleared. 88 Sets the color of the inside of the indicator when cleared.
77 89
90*--inside-caps-lock-color* <rrggbb[aa]>
91 Sets the color of the inside of the indicator when Caps Lock is active.
92
78*--inside-ver-color* <rrggbb[aa]> 93*--inside-ver-color* <rrggbb[aa]>
79 Sets the color of the inside of the indicator when verifying. 94 Sets the color of the inside of the indicator when verifying.
80 95
@@ -92,6 +107,10 @@ Locks your Wayland session.
92 Sets the color of the lines that separate the inside and outside of the 107 Sets the color of the lines that separate the inside and outside of the
93 indicator when cleared. 108 indicator when cleared.
94 109
110*--line-caps-lock-color* <rrggbb[aa]>
111 Sets the color of the line between the inside and ring when Caps Lock
112 is active.
113
95*--line-ver-color* <rrggbb[aa]> 114*--line-ver-color* <rrggbb[aa]>
96 Sets the color of the lines that separate the inside and outside of the 115 Sets the color of the lines that separate the inside and outside of the
97 indicator when verifying. 116 indicator when verifying.
@@ -114,6 +133,9 @@ Locks your Wayland session.
114*--ring-clear-color* <rrggbb[aa]> 133*--ring-clear-color* <rrggbb[aa]>
115 Sets the color of the outside of the indicator when cleared. 134 Sets the color of the outside of the indicator when cleared.
116 135
136*--ring-caps-lock-color* <rrggbb[aa]>
137 Sets the color of the ring of the indicator when Caps Lock is active.
138
117*--ring-ver-color* <rrggbb[aa]> 139*--ring-ver-color* <rrggbb[aa]>
118 Sets the color of the outside of the indicator when verifying. 140 Sets the color of the outside of the indicator when verifying.
119 141
@@ -129,6 +151,9 @@ Locks your Wayland session.
129*--text-clear-color* <rrggbb[aa]> 151*--text-clear-color* <rrggbb[aa]>
130 Sets the color of the text inside the indicator when cleared. 152 Sets the color of the text inside the indicator when cleared.
131 153
154*--text-caps-lock-color* <rrggbb[aa]>
155 Sets the color of the text when Caps Lock is active.
156
132*--text-ver-color* <rrggbb[aa]> 157*--text-ver-color* <rrggbb[aa]>
133 Sets the color of the text inside the indicator when verifying. 158 Sets the color of the text inside the indicator when verifying.
134 159