mirror of
https://github.com/swaywm/sway.git
synced 2025-01-02 10:26:42 +01:00
Documentation and style fixes for swaylock
This commit is contained in:
parent
34e2c70abc
commit
46bd2bb5df
3 changed files with 89 additions and 100 deletions
|
@ -19,6 +19,12 @@ enum auth_state {
|
||||||
AUTH_STATE_INVALID,
|
AUTH_STATE_INVALID,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum line_source {
|
||||||
|
LINE_SOURCE_DEFAULT,
|
||||||
|
LINE_SOURCE_RING,
|
||||||
|
LINE_SOURCE_INSIDE,
|
||||||
|
};
|
||||||
|
|
||||||
struct render_data {
|
struct render_data {
|
||||||
list_t *surfaces;
|
list_t *surfaces;
|
||||||
// Output specific images
|
// Output specific images
|
||||||
|
|
121
swaylock/main.c
121
swaylock/main.c
|
@ -57,7 +57,7 @@ void sway_terminate(int exit_code) {
|
||||||
|
|
||||||
char *password;
|
char *password;
|
||||||
int password_size;
|
int password_size;
|
||||||
int line_source = 0;
|
enum line_source line_source = LINE_SOURCE_DEFAULT;
|
||||||
|
|
||||||
struct lock_config *init_config() {
|
struct lock_config *init_config() {
|
||||||
struct lock_config *config = calloc(1, sizeof(struct lock_config));
|
struct lock_config *config = calloc(1, sizeof(struct lock_config));
|
||||||
|
@ -362,15 +362,15 @@ int main(int argc, char **argv) {
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
{"color", required_argument, NULL, 'c'},
|
{"color", required_argument, NULL, 'c'},
|
||||||
{"image", required_argument, NULL, 'i'},
|
{"image", required_argument, NULL, 'i'},
|
||||||
{"scaling", required_argument, NULL, 's'},
|
{"scaling", required_argument, NULL, 0},
|
||||||
{"tiling", no_argument, NULL, 't'},
|
{"tiling", no_argument, NULL, 't'},
|
||||||
{"version", no_argument, NULL, 'v'},
|
{"version", no_argument, NULL, 'v'},
|
||||||
{"socket", required_argument, NULL, 'p'},
|
{"socket", required_argument, NULL, 'p'},
|
||||||
{"no-unlock-indicator", no_argument, NULL, 'u'},
|
{"no-unlock-indicator", no_argument, NULL, 'u'},
|
||||||
{"daemonize", no_argument, NULL, 'f'},
|
{"daemonize", no_argument, NULL, 'f'},
|
||||||
{"font", required_argument, NULL, 0},
|
{"font", required_argument, NULL, 0},
|
||||||
{"line-uses-ring", no_argument, NULL, 0},
|
{"line-uses-ring", no_argument, NULL, 'r'},
|
||||||
{"line-uses-inside", no_argument, NULL, 0},
|
{"line-uses-inside", no_argument, NULL, 's'},
|
||||||
{"textcolor", required_argument, NULL, 0},
|
{"textcolor", required_argument, NULL, 0},
|
||||||
{"insidevercolor", required_argument, NULL, 0},
|
{"insidevercolor", required_argument, NULL, 0},
|
||||||
{"insidewrongcolor", required_argument, NULL, 0},
|
{"insidewrongcolor", required_argument, NULL, 0},
|
||||||
|
@ -390,25 +390,14 @@ int main(int argc, char **argv) {
|
||||||
"\n"
|
"\n"
|
||||||
" -h, --help Show help message and quit.\n"
|
" -h, --help Show help message and quit.\n"
|
||||||
" -c, --color <rrggbb[aa]> Turn the screen into the given color instead of white.\n"
|
" -c, --color <rrggbb[aa]> Turn the screen into the given color instead of white.\n"
|
||||||
" -s, --scaling Scaling mode: stretch, fill, fit, center, tile.\n"
|
" --scaling Scaling mode: stretch, fill, fit, center, tile.\n"
|
||||||
" -t, --tiling Same as --scaling=tile.\n"
|
" -t, --tiling Same as --scaling=tile.\n"
|
||||||
" -v, --version Show the version number and quit.\n"
|
" -v, --version Show the version number and quit.\n"
|
||||||
" -i, --image [<output>:]<path> Display the given image.\n"
|
" -i, --image [<output>:]<path> Display the given image.\n"
|
||||||
" -u, --no-unlock-indicator Disable the unlock indicator.\n"
|
" -u, --no-unlock-indicator Disable the unlock indicator.\n"
|
||||||
" -f, --daemonize Detach from the controlling terminal.\n"
|
" -f, --daemonize Detach from the controlling terminal.\n"
|
||||||
" --socket <socket> Use the specified socket.\n"
|
" --socket <socket> Use the specified socket.\n"
|
||||||
" --font <font> Use the specified font instead of sans-serif.\n"
|
" For more information see `man swaylock`\n";
|
||||||
" --textcolor <rrggbb[aa]> Sets the color of the text.\n"
|
|
||||||
" --insidevercolor <rrggbb[aa]> Sets the color of the verifying indicator circle.\n"
|
|
||||||
" --insidewrongcolor <rrggbb[aa]> Sets the color of the invalid indicator circle.\n"
|
|
||||||
" --insidecolor <rrggbb[aa]> Sets the color of the typing or idle indicator circle.\n"
|
|
||||||
" --ringvercolor <rrggbb[aa]> Sets the color of the verifying indicator ring.\n"
|
|
||||||
" --ringwrongcolor <rrggbb[aa]> Sets the color of the invalid indicator ring.\n"
|
|
||||||
" --ringcolor <rrggbb[aa]> Sets the color of the typing or idle indicator ring.\n"
|
|
||||||
" --linecolor <rrggbb[aa]> Sets the color of the line that separates the indicator.\n"
|
|
||||||
" --separatorcolor <rrggbb[aa]> Sets the color of the line that separates highlight segments.\n"
|
|
||||||
" --keyhlcolor <rrggbb[aa]> Sets the color of keypress highlight segments.\n"
|
|
||||||
" --bshlcolor <rrggbb[aa]> Sets the color of keypress highlight segments.\n";
|
|
||||||
|
|
||||||
|
|
||||||
registry = registry_poll();
|
registry = registry_poll();
|
||||||
|
@ -416,7 +405,7 @@ int main(int argc, char **argv) {
|
||||||
int c;
|
int c;
|
||||||
while (1) {
|
while (1) {
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
c = getopt_long(argc, argv, "hc:i:s:tvuf", long_options, &option_index);
|
c = getopt_long(argc, argv, "hc:i:srtvuf", long_options, &option_index);
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -454,9 +443,6 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 's':
|
|
||||||
scaling_mode_str = optarg;
|
|
||||||
break;
|
|
||||||
case 't':
|
case 't':
|
||||||
scaling_mode_str = "tile";
|
scaling_mode_str = "tile";
|
||||||
break;
|
break;
|
||||||
|
@ -480,56 +466,47 @@ int main(int argc, char **argv) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'r':
|
||||||
|
if (line_source != LINE_SOURCE_DEFAULT) {
|
||||||
|
sway_log(L_ERROR, "line source options conflict");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
line_source = LINE_SOURCE_RING;
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
if (line_source != LINE_SOURCE_DEFAULT) {
|
||||||
|
sway_log(L_ERROR, "line source options conflict");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
line_source = LINE_SOURCE_INSIDE;
|
||||||
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
if (strcmp(long_options[option_index].name, "font") == 0) {
|
if (strcmp(long_options[option_index].name, "font") == 0) {
|
||||||
free(config->font);
|
free(config->font);
|
||||||
config->font = strdup(optarg);
|
config->font = strdup(optarg);
|
||||||
}
|
} else if (strcmp(long_options[option_index].name, "scaling") == 0) {
|
||||||
else if (strcmp(long_options[option_index].name, "line-uses-ring") == 0) {
|
scaling_mode_str = optarg;
|
||||||
if (line_source != 0) {
|
} else if (strcmp(long_options[option_index].name, "textcolor") == 0) {
|
||||||
sway_log(L_ERROR, "Line source options conflict");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
line_source = 1;
|
|
||||||
}
|
|
||||||
else if (strcmp(long_options[option_index].name, "line-uses-inside") == 0) {
|
|
||||||
if (line_source != 0) {
|
|
||||||
sway_log(L_ERROR, "Line source options conflict");
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
line_source = 2;
|
|
||||||
}
|
|
||||||
else if (strcmp(long_options[option_index].name, "textcolor") == 0) {
|
|
||||||
config->colors.text = parse_color(optarg);
|
config->colors.text = parse_color(optarg);
|
||||||
}
|
} else if (strcmp(long_options[option_index].name, "insidevercolor") == 0) {
|
||||||
else if (strcmp(long_options[option_index].name, "insidevercolor") == 0) {
|
|
||||||
config->colors.validating.inner_ring = parse_color(optarg);
|
config->colors.validating.inner_ring = parse_color(optarg);
|
||||||
}
|
} else if (strcmp(long_options[option_index].name, "insidewrongcolor") == 0) {
|
||||||
else if (strcmp(long_options[option_index].name, "insidewrongcolor") == 0) {
|
|
||||||
config->colors.invalid.inner_ring = parse_color(optarg);
|
config->colors.invalid.inner_ring = parse_color(optarg);
|
||||||
}
|
} else if (strcmp(long_options[option_index].name, "insidecolor") == 0) {
|
||||||
else if (strcmp(long_options[option_index].name, "insidecolor") == 0) {
|
|
||||||
config->colors.normal.inner_ring = parse_color(optarg);
|
config->colors.normal.inner_ring = parse_color(optarg);
|
||||||
}
|
} else if (strcmp(long_options[option_index].name, "ringvercolor") == 0) {
|
||||||
else if (strcmp(long_options[option_index].name, "ringvercolor") == 0) {
|
|
||||||
config->colors.validating.outer_ring = parse_color(optarg);
|
config->colors.validating.outer_ring = parse_color(optarg);
|
||||||
}
|
} else if (strcmp(long_options[option_index].name, "ringwrongcolor") == 0) {
|
||||||
else if (strcmp(long_options[option_index].name, "ringwrongcolor") == 0) {
|
|
||||||
config->colors.invalid.outer_ring = parse_color(optarg);
|
config->colors.invalid.outer_ring = parse_color(optarg);
|
||||||
}
|
} else if (strcmp(long_options[option_index].name, "ringcolor") == 0) {
|
||||||
else if (strcmp(long_options[option_index].name, "ringcolor") == 0) {
|
|
||||||
config->colors.normal.outer_ring = parse_color(optarg);
|
config->colors.normal.outer_ring = parse_color(optarg);
|
||||||
}
|
} else if (strcmp(long_options[option_index].name, "linecolor") == 0) {
|
||||||
else if (strcmp(long_options[option_index].name, "linecolor") == 0) {
|
|
||||||
config->colors.line = parse_color(optarg);
|
config->colors.line = parse_color(optarg);
|
||||||
}
|
} else if (strcmp(long_options[option_index].name, "separatorcolor") == 0) {
|
||||||
else if (strcmp(long_options[option_index].name, "separatorcolor") == 0) {
|
|
||||||
config->colors.separator = parse_color(optarg);
|
config->colors.separator = parse_color(optarg);
|
||||||
}
|
} else if (strcmp(long_options[option_index].name, "keyhlcolor") == 0) {
|
||||||
else if (strcmp(long_options[option_index].name, "keyhlcolor") == 0) {
|
|
||||||
config->colors.input_cursor = parse_color(optarg);
|
config->colors.input_cursor = parse_color(optarg);
|
||||||
}
|
} else if (strcmp(long_options[option_index].name, "bshlcolor") == 0) {
|
||||||
else if (strcmp(long_options[option_index].name, "bshlcolor") == 0) {
|
|
||||||
config->colors.backspace_cursor = parse_color(optarg);
|
config->colors.backspace_cursor = parse_color(optarg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -783,39 +760,35 @@ void render(struct render_data *render_data, struct lock_config *config) {
|
||||||
cairo_stroke(window->cairo);
|
cairo_stroke(window->cairo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line_source == 1) {
|
switch(line_source) {
|
||||||
|
case LINE_SOURCE_RING:
|
||||||
switch(render_data->auth_state) {
|
switch(render_data->auth_state) {
|
||||||
case AUTH_STATE_VALIDATING: {
|
case AUTH_STATE_VALIDATING:
|
||||||
cairo_set_source_u32(window->cairo, config->colors.validating.outer_ring);
|
cairo_set_source_u32(window->cairo, config->colors.validating.outer_ring);
|
||||||
break;
|
break;
|
||||||
}
|
case AUTH_STATE_INVALID:
|
||||||
case AUTH_STATE_INVALID: {
|
|
||||||
cairo_set_source_u32(window->cairo, config->colors.invalid.outer_ring);
|
cairo_set_source_u32(window->cairo, config->colors.invalid.outer_ring);
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
default: {
|
|
||||||
cairo_set_source_u32(window->cairo, config->colors.normal.outer_ring);
|
cairo_set_source_u32(window->cairo, config->colors.normal.outer_ring);
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
}
|
case LINE_SOURCE_INSIDE:
|
||||||
else if (line_source == 2) {
|
|
||||||
switch(render_data->auth_state) {
|
switch(render_data->auth_state) {
|
||||||
case AUTH_STATE_VALIDATING: {
|
case AUTH_STATE_VALIDATING:
|
||||||
cairo_set_source_u32(window->cairo, config->colors.validating.inner_ring);
|
cairo_set_source_u32(window->cairo, config->colors.validating.inner_ring);
|
||||||
break;
|
break;
|
||||||
}
|
case AUTH_STATE_INVALID:
|
||||||
case AUTH_STATE_INVALID: {
|
|
||||||
cairo_set_source_u32(window->cairo, config->colors.invalid.inner_ring);
|
cairo_set_source_u32(window->cairo, config->colors.invalid.inner_ring);
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
default: {
|
|
||||||
cairo_set_source_u32(window->cairo, config->colors.normal.inner_ring);
|
cairo_set_source_u32(window->cairo, config->colors.normal.inner_ring);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
}
|
default:
|
||||||
else {
|
|
||||||
cairo_set_source_u32(window->cairo, config->colors.line);
|
cairo_set_source_u32(window->cairo, config->colors.line);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
// Draw inner + outer border of the circle
|
// Draw inner + outer border of the circle
|
||||||
cairo_set_line_width(window->cairo, 2.0);
|
cairo_set_line_width(window->cairo, 2.0);
|
||||||
|
|
|
@ -29,7 +29,7 @@ Options
|
||||||
*-i, \--image* [<output>:]<path>::
|
*-i, \--image* [<output>:]<path>::
|
||||||
Display the given image, optionally only on the given output.
|
Display the given image, optionally only on the given output.
|
||||||
|
|
||||||
*-s, \--scaling*::
|
*--scaling*::
|
||||||
Scaling mode for images: stretch, fill, fit, center, or tile.
|
Scaling mode for images: stretch, fill, fit, center, or tile.
|
||||||
|
|
||||||
*-t, --tiling*::
|
*-t, --tiling*::
|
||||||
|
@ -45,11 +45,17 @@ Options
|
||||||
Use the specified socket path. Otherwise, swaymsg will ask sway where the
|
Use the specified socket path. Otherwise, swaymsg will ask sway where the
|
||||||
socket is (which is the value of $SWAYSOCK, then of $I3SOCK).
|
socket is (which is the value of $SWAYSOCK, then of $I3SOCK).
|
||||||
|
|
||||||
|
Appearance
|
||||||
|
----------
|
||||||
|
|
||||||
|
*--bshlcolor* <rrggbb[aa]>::
|
||||||
|
Sets the color of backspace highlight segments.
|
||||||
|
|
||||||
*--font* <font>::
|
*--font* <font>::
|
||||||
Sets the font of the text inside the indicator.
|
Sets the font of the text inside the indicator.
|
||||||
|
|
||||||
*--textcolor* <rrggbb[aa]>::
|
*--insidecolor* <rrggbb[aa]>::
|
||||||
Sets the color of the text inside the indicator.
|
Sets the color of the inside of the indicator when typing or idle.
|
||||||
|
|
||||||
*--insidevercolor* <rrggbb[aa]>::
|
*--insidevercolor* <rrggbb[aa]>::
|
||||||
Sets the color of the inside of the indicator when verifying.
|
Sets the color of the inside of the indicator when verifying.
|
||||||
|
@ -57,8 +63,23 @@ Options
|
||||||
*--insidewrongcolor* <rrggbb[aa]>::
|
*--insidewrongcolor* <rrggbb[aa]>::
|
||||||
Sets the color of the inside of the indicator when invalid.
|
Sets the color of the inside of the indicator when invalid.
|
||||||
|
|
||||||
*--insidecolor* <rrggbb[aa]>::
|
*--keyhlcolor* <rrggbb[aa]>::
|
||||||
Sets the color of the inside of the indicator when typing or idle.
|
Sets the color of keypress highlight segments.
|
||||||
|
|
||||||
|
*--linecolor* <rrggbb[aa]>::
|
||||||
|
Sets the color of the lines that separate the inside and outside of the
|
||||||
|
indicator.
|
||||||
|
|
||||||
|
*-s, \--line-uses-inside*::
|
||||||
|
Use the color of the inside of the indicator for the line separating the
|
||||||
|
inside and outside of the indicator.
|
||||||
|
|
||||||
|
*-r, \--line-uses-ring*::
|
||||||
|
Use the outer ring's color for the line separating the inside and outside of
|
||||||
|
the indicator.
|
||||||
|
|
||||||
|
*--ringcolor* <rrggbb[aa]>::
|
||||||
|
Sets the color of the outside of the indicator when typing or idle.
|
||||||
|
|
||||||
*--ringvercolor* <rrggbb[aa]>::
|
*--ringvercolor* <rrggbb[aa]>::
|
||||||
Sets the color of the outside of the indicator when verifying.
|
Sets the color of the outside of the indicator when verifying.
|
||||||
|
@ -66,22 +87,11 @@ Options
|
||||||
*--ringwrongcolor* <rrggbb[aa]>::
|
*--ringwrongcolor* <rrggbb[aa]>::
|
||||||
Sets the color of the outside of the indicator when invalid.
|
Sets the color of the outside of the indicator when invalid.
|
||||||
|
|
||||||
*--ringcolor* <rrggbb[aa]>::
|
|
||||||
Sets the color of the outside of the indicator when typing or idle.
|
|
||||||
|
|
||||||
*--linecolor* <rrggbb[aa]>::
|
|
||||||
Sets the color of the lines that separate the inside and outside of the
|
|
||||||
indicator.
|
|
||||||
|
|
||||||
*--separatorcolor* <rrggbb[aa]>::
|
*--separatorcolor* <rrggbb[aa]>::
|
||||||
Sets the color of the lines that seperate highlight segments.
|
Sets the color of the lines that seperate highlight segments.
|
||||||
|
|
||||||
*--keyhlcolor* <rrggbb[aa]>::
|
*--textcolor* <rrggbb[aa]>::
|
||||||
Sets the color of keypress highlight segments.
|
Sets the color of the text inside the indicator.
|
||||||
|
|
||||||
*--bshlcolor* <rrggbb[aa]>::
|
|
||||||
Sets the color of backspace highlight segments.
|
|
||||||
|
|
||||||
|
|
||||||
Authors
|
Authors
|
||||||
-------
|
-------
|
||||||
|
|
Loading…
Reference in a new issue