summaryrefslogtreecommitdiffstats
path: root/swaylock/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaylock/main.c')
-rw-r--r--swaylock/main.c153
1 files changed, 118 insertions, 35 deletions
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);