diff options
Diffstat (limited to 'swaylock')
| -rw-r--r-- | swaylock/main.c | 192 | ||||
| -rw-r--r-- | swaylock/pam.c | 2 | ||||
| -rw-r--r-- | swaylock/password.c | 96 | ||||
| -rw-r--r-- | swaylock/render.c | 28 | ||||
| -rw-r--r-- | swaylock/seat.c | 6 | ||||
| -rw-r--r-- | swaylock/shadow.c | 2 | ||||
| -rw-r--r-- | swaylock/swaylock.1.scd | 27 | 
7 files changed, 240 insertions, 113 deletions
| diff --git a/swaylock/main.c b/swaylock/main.c index 9b74b671..0b167da1 100644 --- a/swaylock/main.c +++ b/swaylock/main.c @@ -1,10 +1,10 @@ -#define _XOPEN_SOURCE 700 -#define _POSIX_C_SOURCE 200112L +#define _POSIX_C_SOURCE 200809L  #include <assert.h>  #include <ctype.h>  #include <errno.h>  #include <fcntl.h>  #include <getopt.h> +#include <poll.h>  #include <stdbool.h>  #include <stdio.h>  #include <stdlib.h> @@ -23,7 +23,6 @@  #include "cairo.h"  #include "log.h"  #include "loop.h" -#include "readline.h"  #include "stringop.h"  #include "util.h"  #include "wlr-input-inhibitor-unstable-v1-client-protocol.h" @@ -397,28 +396,34 @@ static void set_default_colors(struct swaylock_colors *colors) {  	colors->background = 0xFFFFFFFF;  	colors->bs_highlight = 0xDB3300FF;  	colors->key_highlight = 0x33DB00FF; +	colors->caps_lock_bs_highlight = 0xDB3300FF; +	colors->caps_lock_key_highlight = 0x33DB00FF;  	colors->separator = 0x000000FF;  	colors->inside = (struct swaylock_colorset){  		.input = 0x000000C0,  		.cleared = 0xE5A445C0, +		.caps_lock = 0x000000C0,  		.verifying = 0x0072FFC0,  		.wrong = 0xFA0000C0,  	};  	colors->line = (struct swaylock_colorset){  		.input = 0x000000FF,  		.cleared = 0x000000FF, +		.caps_lock = 0x000000FF,  		.verifying = 0x000000FF,  		.wrong = 0x000000FF,  	};  	colors->ring = (struct swaylock_colorset){  		.input = 0x337D00FF,  		.cleared = 0xE5A445FF, +		.caps_lock = 0xE5A445FF,  		.verifying = 0x3300FFFF,  		.wrong = 0x7D3300FF,  	};  	colors->text = (struct swaylock_colorset){  		.input = 0xE5A445FF,  		.cleared = 0x000000FF, +		.caps_lock = 0xE5A445FF,  		.verifying = 0x000000FF,  		.wrong = 0x000000FF,  	}; @@ -434,25 +439,31 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,  		enum line_mode *line_mode, char **config_path) {  	enum long_option_codes {  		LO_BS_HL_COLOR = 256, +		LO_CAPS_LOCK_BS_HL_COLOR, +		LO_CAPS_LOCK_KEY_HL_COLOR,  		LO_FONT,  		LO_IND_RADIUS,  		LO_IND_THICKNESS,  		LO_INSIDE_COLOR,  		LO_INSIDE_CLEAR_COLOR, +		LO_INSIDE_CAPS_LOCK_COLOR,  		LO_INSIDE_VER_COLOR,  		LO_INSIDE_WRONG_COLOR,  		LO_KEY_HL_COLOR,  		LO_LINE_COLOR,  		LO_LINE_CLEAR_COLOR, +		LO_LINE_CAPS_LOCK_COLOR,  		LO_LINE_VER_COLOR,  		LO_LINE_WRONG_COLOR,  		LO_RING_COLOR,  		LO_RING_CLEAR_COLOR, +		LO_RING_CAPS_LOCK_COLOR,  		LO_RING_VER_COLOR,  		LO_RING_WRONG_COLOR,  		LO_SEP_COLOR,  		LO_TEXT_COLOR,  		LO_TEXT_CLEAR_COLOR, +		LO_TEXT_CAPS_LOCK_COLOR,  		LO_TEXT_VER_COLOR,  		LO_TEXT_WRONG_COLOR,  	}; @@ -464,6 +475,8 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,  		{"daemonize", no_argument, NULL, 'f'},  		{"help", no_argument, NULL, 'h'},  		{"image", required_argument, NULL, 'i'}, +		{"disable-caps-lock-text", no_argument, NULL, 'L'}, +		{"indicator-caps-lock", no_argument, NULL, 'l'},  		{"line-uses-inside", no_argument, NULL, 'n'},  		{"socket", required_argument, NULL, 'p'},  		{"line-uses-ring", no_argument, NULL, 'r'}, @@ -472,25 +485,31 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,  		{"no-unlock-indicator", no_argument, NULL, 'u'},  		{"version", no_argument, NULL, 'v'},  		{"bs-hl-color", required_argument, NULL, LO_BS_HL_COLOR}, +		{"caps-lock-bs-hl-color", required_argument, NULL, LO_CAPS_LOCK_BS_HL_COLOR}, +		{"caps-lock-key-hl-color", required_argument, NULL, LO_CAPS_LOCK_KEY_HL_COLOR},  		{"font", required_argument, NULL, LO_FONT},  		{"indicator-radius", required_argument, NULL, LO_IND_RADIUS},  		{"indicator-thickness", required_argument, NULL, LO_IND_THICKNESS},  		{"inside-color", required_argument, NULL, LO_INSIDE_COLOR},  		{"inside-clear-color", required_argument, NULL, LO_INSIDE_CLEAR_COLOR}, +		{"inside-caps-lock-color", required_argument, NULL, LO_INSIDE_CAPS_LOCK_COLOR},  		{"inside-ver-color", required_argument, NULL, LO_INSIDE_VER_COLOR},  		{"inside-wrong-color", required_argument, NULL, LO_INSIDE_WRONG_COLOR},  		{"key-hl-color", required_argument, NULL, LO_KEY_HL_COLOR},  		{"line-color", required_argument, NULL, LO_LINE_COLOR},  		{"line-clear-color", required_argument, NULL, LO_LINE_CLEAR_COLOR}, +		{"line-caps-lock-color", required_argument, NULL, LO_LINE_CAPS_LOCK_COLOR},  		{"line-ver-color", required_argument, NULL, LO_LINE_VER_COLOR},  		{"line-wrong-color", required_argument, NULL, LO_LINE_WRONG_COLOR},  		{"ring-color", required_argument, NULL, LO_RING_COLOR},  		{"ring-clear-color", required_argument, NULL, LO_RING_CLEAR_COLOR}, +		{"ring-caps-lock-color", required_argument, NULL, LO_RING_CAPS_LOCK_COLOR},  		{"ring-ver-color", required_argument, NULL, LO_RING_VER_COLOR},  		{"ring-wrong-color", required_argument, NULL, LO_RING_WRONG_COLOR},  		{"separator-color", required_argument, NULL, LO_SEP_COLOR},  		{"text-color", required_argument, NULL, LO_TEXT_COLOR},  		{"text-clear-color", required_argument, NULL, LO_TEXT_CLEAR_COLOR}, +		{"text-caps-lock-color", required_argument, NULL, LO_TEXT_CAPS_LOCK_COLOR},  		{"text-ver-color", required_argument, NULL, LO_TEXT_VER_COLOR},  		{"text-wrong-color", required_argument, NULL, LO_TEXT_WRONG_COLOR},  		{0, 0, 0, 0} @@ -499,76 +518,97 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,  	const char usage[] =  		"Usage: swaylock [options...]\n"  		"\n" -		"  -C, --config <config_file>     " +		"  -C, --config <config_file>       "  			"Path to the config file.\n" -		"  -c, --color <color>            " +		"  -c, --color <color>              "  			"Turn the screen into the given color instead of white.\n" -		"  -e, --ignore-empty-password    " +		"  -e, --ignore-empty-password      "  			"When an empty password is provided, do not validate it.\n" -		"  -f, --daemonize                " +		"  -f, --daemonize                  "  			"Detach from the controlling terminal after locking.\n" -		"  -h, --help                     " +		"  -h, --help                       "  			"Show help message and quit.\n" -		"  -i, --image [<output>:]<path>  " +		"  -i, --image [<output>:]<path>    "  			"Display the given image.\n" -		"  -s, --scaling <mode>           " +		"  -L, --disable-caps-lock-text     " +			"Disable the Caps Lock text.\n" +		"  -l, --indicator-caps-lock        " +			"Show the current Caps Lock state also on the indicator.\n" +		"  -s, --scaling <mode>             "  			"Scaling mode: stretch, fill, fit, center, tile.\n" -		"  -t, --tiling                   " +		"  -t, --tiling                     "  			"Same as --scaling=tile.\n" -		"  -u, --no-unlock-indicator      " +		"  -u, --no-unlock-indicator        "  			"Disable the unlock indicator.\n" -		"  -v, --version                  " +		"  -v, --version                    "  			"Show the version number and quit.\n" -		"  --bs-hl-color <color>          " +		"  --bs-hl-color <color>            "  			"Sets the color of backspace highlight segments.\n" -		"  --font <font>                  " +		"  --caps-lock-bs-hl-color <color>  " +			"Sets the color of backspace highlight segments when Caps Lock " +			"is active.\n" +		"  --caps-lock-key-hl-color <color> " +			"Sets the color of the key press highlight segments when " +			"Caps Lock is active.\n" +		"  --font <font>                    "  			"Sets the font of the text.\n" -		"  --indicator-radius <radius>    " +		"  --indicator-radius <radius>      "  			"Sets the indicator radius.\n" -		"  --indicator-thickness <thick>  " +		"  --indicator-thickness <thick>    "  			"Sets the indicator thickness.\n" -		"  --inside-color <color>         " +		"  --inside-color <color>           "  			"Sets the color of the inside of the indicator.\n" -		"  --inside-clear-color <color>   " +		"  --inside-clear-color <color>     "  			"Sets the color of the inside of the indicator when cleared.\n" -		"  --inside-ver-color <color>     " +		"  --inside-caps-lock-color <color> " +			"Sets the color of the inside of the indicator when Caps Lock " +			"is active.\n" +		"  --inside-ver-color <color>       "  			"Sets the color of the inside of the indicator when verifying.\n" -		"  --inside-wrong-color <color>   " +		"  --inside-wrong-color <color>     "  			"Sets the color of the inside of the indicator when invalid.\n" -		"  --key-hl-color <color>         " +		"  --key-hl-color <color>           "  			"Sets the color of the key press highlight segments.\n" -		"  --line-color <color>           " +		"  --line-color <color>             "  			"Sets the color of the line between the inside and ring.\n" -		"  --line-clear-color <color>     " +		"  --line-clear-color <color>       "  			"Sets the color of the line between the inside and ring when "  			"cleared.\n" -		"  --line-ver-color <color>       " +		"  --line-caps-lock-color <color>   " +			"Sets the color of the line between the inside and ring when " +			"Caps Lock is active.\n" +		"  --line-ver-color <color>         "  			"Sets the color of the line between the inside and ring when "  			"verifying.\n" -		"  --line-wrong-color <color>     " +		"  --line-wrong-color <color>       "  			"Sets the color of the line between the inside and ring when "  			"invalid.\n" -		"  -n, --line-uses-inside         " +		"  -n, --line-uses-inside           "  			"Use the inside color for the line between the inside and ring.\n" -		"  -r, --line-uses-ring           " +		"  -r, --line-uses-ring             "  			"Use the ring color for the line between the inside and ring.\n" -		"  --ring-color <color>           " +		"  --ring-color <color>             "  			"Sets the color of the ring of the indicator.\n" -		"  --ring-clear-color <color>     " +		"  --ring-clear-color <color>       "  			"Sets the color of the ring of the indicator when cleared.\n" -		"  --ring-ver-color <color>       " +		"  --ring-caps-lock-color <color>   " +			"Sets the color of the ring of the indicator when Caps Lock " +			"is active.\n" +		"  --ring-ver-color <color>         "  			"Sets the color of the ring of the indicator when verifying.\n" -		"  --ring-wrong-color <color>     " +		"  --ring-wrong-color <color>       "  			"Sets the color of the ring of the indicator when invalid.\n" -		"  --separator-color <color>      " +		"  --separator-color <color>        "  			"Sets the color of the lines that separate highlight segments.\n" -		"  --text-color <color>           " +		"  --text-color <color>             "  			"Sets the color of the text.\n" -		"  --text-clear-color <color>     " +		"  --text-clear-color <color>       "  			"Sets the color of the text when cleared.\n" -		"  --text-ver-color <color>       " +		"  --text-caps-lock-color <color>   " +			"Sets the color of the text when Caps Lock is active.\n" +		"  --text-ver-color <color>         "  			"Sets the color of the text when verifying.\n" -		"  --text-wrong-color <color>     " +		"  --text-wrong-color <color>       "  			"Sets the color of the text when invalid.\n"  		"\n"  		"All <color> options are of the form <rrggbb[aa]>.\n"; @@ -577,7 +617,7 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,  	optind = 1;  	while (1) {  		int opt_idx = 0; -		c = getopt_long(argc, argv, "c:efhi:nrs:tuvC:", long_options, &opt_idx); +		c = getopt_long(argc, argv, "c:efhi:Llnrs:tuvC:", long_options, &opt_idx);  		if (c == -1) {  			break;  		} @@ -608,6 +648,16 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,  				load_image(optarg, state);  			}  			break; +		case 'L': +			if (state) { +				state->args.show_caps_lock_text = false; +			} +			break; +		case 'l': +			if (state) { +				state->args.show_caps_lock_indicator = true; +			} +			break;  		case 'n':  			if (line_mode) {  				*line_mode = LM_INSIDE; @@ -645,6 +695,16 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,  				state->args.colors.bs_highlight = parse_color(optarg);  			}  			break; +		case LO_CAPS_LOCK_BS_HL_COLOR: +			if (state) { +				state->args.colors.caps_lock_bs_highlight = parse_color(optarg); +			} +			break; +		case LO_CAPS_LOCK_KEY_HL_COLOR: +			if (state) { +				state->args.colors.caps_lock_key_highlight = parse_color(optarg); +			} +			break;  		case LO_FONT:  			if (state) {  				free(state->args.font); @@ -671,6 +731,11 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,  				state->args.colors.inside.cleared = parse_color(optarg);  			}  			break; +		case LO_INSIDE_CAPS_LOCK_COLOR: +			if (state) { +				state->args.colors.inside.caps_lock = parse_color(optarg); +			} +			break;  		case LO_INSIDE_VER_COLOR:  			if (state) {  				state->args.colors.inside.verifying = parse_color(optarg); @@ -696,6 +761,11 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,  				state->args.colors.line.cleared = parse_color(optarg);  			}  			break; +		case LO_LINE_CAPS_LOCK_COLOR: +			if (state) { +				state->args.colors.line.caps_lock = parse_color(optarg); +			} +			break;  		case LO_LINE_VER_COLOR:  			if (state) {  				state->args.colors.line.verifying = parse_color(optarg); @@ -716,6 +786,11 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,  				state->args.colors.ring.cleared = parse_color(optarg);  			}  			break; +		case LO_RING_CAPS_LOCK_COLOR: +			if (state) { +				state->args.colors.ring.caps_lock = parse_color(optarg); +			} +			break;  		case LO_RING_VER_COLOR:  			if (state) {  				state->args.colors.ring.verifying = parse_color(optarg); @@ -741,6 +816,11 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,  				state->args.colors.text.cleared = parse_color(optarg);  			}  			break; +		case LO_TEXT_CAPS_LOCK_COLOR: +			if (state) { +				state->args.colors.text.caps_lock = parse_color(optarg); +			} +			break;  		case LO_TEXT_VER_COLOR:  			if (state) {  				state->args.colors.text.verifying = parse_color(optarg); @@ -808,36 +888,32 @@ static int load_config(char *path, struct swaylock_state *state,  		wlr_log(WLR_ERROR, "Failed to read config. Running without it.");  		return 0;  	} -	char *line; +	char *line = NULL; +	size_t line_size = 0; +	ssize_t nread;  	int line_number = 0; -	while (!feof(config)) { -		line = read_line(config); -		if (!line) { -			continue; -		} - +	int result = 0; +	while ((nread = getline(&line, &line_size, config)) != -1) {  		line_number++; -		if (line[0] == '#') { -			free(line); -			continue; + +		if (line[nread - 1] == '\n') { +			line[--nread] = '\0';  		} -		if (strlen(line) == 0) { -			free(line); + +		if (!*line || line[0] == '#') {  			continue;  		}  		wlr_log(WLR_DEBUG, "Config Line #%d: %s", line_number, line); -		char flag[strlen(line) + 3]; +		char flag[nread + 3];  		sprintf(flag, "--%s", line);  		char *argv[] = {"swaylock", flag}; -		int result = parse_options(2, argv, state, line_mode, NULL); +		result = parse_options(2, argv, state, line_mode, NULL);  		if (result != 0) { -			free(line); -			fclose(config); -			return result; +			break;  		} -		free(line);  	} +	free(line);  	fclose(config);  	return 0;  } @@ -862,6 +938,8 @@ int main(int argc, char **argv) {  		.thickness = 10,  		.ignore_empty = false,  		.show_indicator = true, +		.show_caps_lock_indicator = false, +		.show_caps_lock_text = true  	};  	wl_list_init(&state.images);  	set_default_colors(&state.args.colors); @@ -962,7 +1040,7 @@ int main(int argc, char **argv) {  	}  	state.eventloop = loop_create(); -	loop_add_fd(state.eventloop, wl_display_get_fd(state.display), POLL_IN, +	loop_add_fd(state.eventloop, wl_display_get_fd(state.display), POLLIN,  			display_in, NULL);  	state.run_display = true; diff --git a/swaylock/pam.c b/swaylock/pam.c index cac95a85..b90d9e87 100644 --- a/swaylock/pam.c +++ b/swaylock/pam.c @@ -1,4 +1,4 @@ -#define _XOPEN_SOURCE 500 +#define _POSIX_C_SOURCE 200809L  #include <pwd.h>  #include <security/pam_appl.h>  #include <stdbool.h> diff --git a/swaylock/password.c b/swaylock/password.c index 6138e1fe..3bd113ad 100644 --- a/swaylock/password.c +++ b/swaylock/password.c @@ -1,4 +1,3 @@ -#define _XOPEN_SOURCE 500  #include <assert.h>  #include <errno.h>  #include <pwd.h> @@ -78,52 +77,56 @@ static void handle_preverify_timeout(void *data) {  	state->verify_password_timer = NULL;  } -void swaylock_handle_key(struct swaylock_state *state, -		xkb_keysym_t keysym, uint32_t codepoint) { -	switch (keysym) { -	case XKB_KEY_KP_Enter: /* fallthrough */ -	case XKB_KEY_Return: -		if (state->args.ignore_empty && state->password.len == 0) { -			break; -		} +static void submit_password(struct swaylock_state *state) { +	if (state->args.ignore_empty && state->password.len == 0) { +		return; +	} -		state->auth_state = AUTH_STATE_VALIDATING; -		damage_state(state); +	state->auth_state = AUTH_STATE_VALIDATING; +	damage_state(state); -		// We generally want to wait until all surfaces are showing the -		// "verifying" state before we go and verify the password, because -		// verifying it is a blocking operation. However, if the surface is on -		// an output with DPMS off then it won't update, so we set a timer. -		state->verify_password_timer = loop_add_timer( -				state->eventloop, 50, handle_preverify_timeout, state); +	// We generally want to wait until all surfaces are showing the +	// "verifying" state before we go and verify the password, because +	// verifying it is a blocking operation. However, if the surface is on +	// an output with DPMS off then it won't update, so we set a timer. +	state->verify_password_timer = loop_add_timer( +			state->eventloop, 50, handle_preverify_timeout, state); -		while (state->run_display && state->verify_password_timer) { -			errno = 0; -			if (wl_display_flush(state->display) == -1 && errno != EAGAIN) { -				break; -			} -			loop_poll(state->eventloop); +	while (state->run_display && state->verify_password_timer) { +		errno = 0; +		if (wl_display_flush(state->display) == -1 && errno != EAGAIN) { +			break; +		} +		loop_poll(state->eventloop); -			bool ok = 1; -			struct swaylock_surface *surface; -			wl_list_for_each(surface, &state->surfaces, link) { -				if (surface->dirty) { -					ok = 0; -				} -			} -			if (ok) { -				break; +		bool ok = 1; +		struct swaylock_surface *surface; +		wl_list_for_each(surface, &state->surfaces, link) { +			if (surface->dirty) { +				ok = 0;  			}  		} -		wl_display_flush(state->display); - -		if (attempt_password(&state->password)) { -			state->run_display = false; +		if (ok) {  			break;  		} -		state->auth_state = AUTH_STATE_INVALID; -		damage_state(state); -		schedule_indicator_clear(state); +	} +	wl_display_flush(state->display); + +	if (attempt_password(&state->password)) { +		state->run_display = false; +		return; +	} +	state->auth_state = AUTH_STATE_INVALID; +	damage_state(state); +	schedule_indicator_clear(state); +} + +void swaylock_handle_key(struct swaylock_state *state, +		xkb_keysym_t keysym, uint32_t codepoint) { +	switch (keysym) { +	case XKB_KEY_KP_Enter: /* fallthrough */ +	case XKB_KEY_Return: +		submit_password(state);  		break;  	case XKB_KEY_Delete:  	case XKB_KEY_BackSpace: @@ -143,14 +146,6 @@ void swaylock_handle_key(struct swaylock_state *state,  		schedule_indicator_clear(state);  		break;  	case XKB_KEY_Caps_Lock: -		/* The state is getting active after this -		 * so we need to manually toggle it */ -		state->xkb.caps_lock = !state->xkb.caps_lock; -		state->auth_state = AUTH_STATE_INPUT_NOP; -		damage_state(state); -		schedule_indicator_clear(state); -		schedule_password_clear(state); -		break;  	case XKB_KEY_Shift_L:  	case XKB_KEY_Shift_R:  	case XKB_KEY_Control_L: @@ -166,6 +161,13 @@ void swaylock_handle_key(struct swaylock_state *state,  		schedule_indicator_clear(state);  		schedule_password_clear(state);  		break; +	case XKB_KEY_d: +		if (state->xkb.control) { +			submit_password(state); +			break; +		} +		// fallthrough +	case XKB_KEY_c: /* fallthrough */  	case XKB_KEY_u:  		if (state->xkb.control) {  			clear_password_buffer(&state->password); diff --git a/swaylock/render.c b/swaylock/render.c index fa8832bd..5aedaad5 100644 --- a/swaylock/render.c +++ b/swaylock/render.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 199506L  #include <math.h>  #include <stdlib.h>  #include <wayland-client.h> @@ -19,7 +18,17 @@ static void set_color_for_state(cairo_t *cairo, struct swaylock_state *state,  	} else if (state->auth_state == AUTH_STATE_CLEAR) {  		cairo_set_source_u32(cairo, colorset->cleared);  	} else { -		cairo_set_source_u32(cairo, colorset->input); +		if (state->xkb.caps_lock && state->args.show_caps_lock_indicator) { +			cairo_set_source_u32(cairo, colorset->caps_lock); +		} else if (state->xkb.caps_lock && !state->args.show_caps_lock_indicator && +				state->args.show_caps_lock_text) { +			uint32_t inputtextcolor = state->args.colors.text.input; +			state->args.colors.text.input = state->args.colors.text.caps_lock; +			cairo_set_source_u32(cairo, colorset->input); +			state->args.colors.text.input = inputtextcolor; +		} else { +			cairo_set_source_u32(cairo, colorset->input); +		}  	}  } @@ -93,7 +102,8 @@ void render_frame(struct swaylock_surface *surface) {  			break;  		case AUTH_STATE_INPUT:  		case AUTH_STATE_INPUT_NOP: -			if (state->xkb.caps_lock) { +		case AUTH_STATE_BACKSPACE: +			if (state->xkb.caps_lock && state->args.show_caps_lock_text) {  				text = "Caps Lock";  			}  			break; @@ -126,9 +136,17 @@ void render_frame(struct swaylock_surface *surface) {  					arc_radius, highlight_start,  					highlight_start + TYPE_INDICATOR_RANGE);  			if (state->auth_state == AUTH_STATE_INPUT) { -				cairo_set_source_u32(cairo, state->args.colors.key_highlight); +				if (state->xkb.caps_lock && state->args.show_caps_lock_indicator) { +					cairo_set_source_u32(cairo, state->args.colors.caps_lock_key_highlight); +				} else { +					cairo_set_source_u32(cairo, state->args.colors.key_highlight); +				}  			} else { -				cairo_set_source_u32(cairo, state->args.colors.bs_highlight); +				if (state->xkb.caps_lock && state->args.show_caps_lock_indicator) { +					cairo_set_source_u32(cairo, state->args.colors.caps_lock_bs_highlight); +				} else { +					cairo_set_source_u32(cairo, state->args.colors.bs_highlight); +				}  			}  			cairo_stroke(cairo); diff --git a/swaylock/seat.c b/swaylock/seat.c index 7b72114f..f0b1385e 100644 --- a/swaylock/seat.c +++ b/swaylock/seat.c @@ -63,8 +63,12 @@ static void keyboard_modifiers(void *data, struct wl_keyboard *wl_keyboard,  	struct swaylock_state *state = data;  	xkb_state_update_mask(state->xkb.state,  		mods_depressed, mods_latched, mods_locked, 0, 0, group); -	state->xkb.caps_lock = xkb_state_mod_name_is_active(state->xkb.state, +	int caps_lock = xkb_state_mod_name_is_active(state->xkb.state,  		XKB_MOD_NAME_CAPS, XKB_STATE_MODS_LOCKED); +	if (caps_lock != state->xkb.caps_lock) { +		state->xkb.caps_lock = caps_lock; +		damage_state(state); +	}  	state->xkb.control = xkb_state_mod_name_is_active(state->xkb.state,  		XKB_MOD_NAME_CTRL,  		XKB_STATE_MODS_DEPRESSED | XKB_STATE_MODS_LATCHED); diff --git a/swaylock/shadow.c b/swaylock/shadow.c index f928eaa3..b7b10a67 100644 --- a/swaylock/shadow.c +++ b/swaylock/shadow.c @@ -1,4 +1,4 @@ -#define _XOPEN_SOURCE +#define _XOPEN_SOURCE // for crypt  #include <pwd.h>  #include <shadow.h>  #include <stdbool.h> diff --git a/swaylock/swaylock.1.scd b/swaylock/swaylock.1.scd index 8ddc7d3a..2c7979be 100644 --- a/swaylock/swaylock.1.scd +++ b/swaylock/swaylock.1.scd @@ -27,7 +27,7 @@ Locks your Wayland session.  *-f, --daemonize*  	Detach from the controlling terminal after locking. -	Note: this is the default bahavior of i3lock. +	Note: this is the default behavior of i3lock.  *-h, --help*  	Show help message and quit. @@ -44,6 +44,12 @@ Locks your Wayland session.  	Display the given image, optionally only on the given output. Use -c to set  	a background color. +*-L, --disable-caps-lock-text* +	Disable the Caps Lock Text. + +*-l, --indicator-caps-lock* +	Show the current Caps Lock state also on the indicator. +  *-s, --scaling*  	Scaling mode for images: _stretch_, _fill_, _fit_, _center_, or _tile_. @@ -58,6 +64,12 @@ Locks your Wayland session.  *--bs-hl-color* <rrggbb[aa]>  	Sets the color of backspace highlight segments. +*--caps-lock-bs-hl-color* <rrggbb[aa]> +	Sets the color of backspace highlight segments when Caps Lock is active. + +*--caps-lock-bs-hl-color* <rrggbb[aa]> +	Sets the color of the key press highlight segments when Caps Lock is active. +  *--font* <font>  	Sets the font of the text inside the indicator. @@ -75,6 +87,9 @@ Locks your Wayland session.  *--inside-clear-color* <rrggbb[aa]>  	Sets the color of the inside of the indicator when cleared. +*--inside-caps-lock-color* <rrggbb[aa]> +	Sets the color of the inside of the indicator when Caps Lock is active. +  *--inside-ver-color* <rrggbb[aa]>  	Sets the color of the inside of the indicator when verifying. @@ -92,6 +107,10 @@ Locks your Wayland session.  	Sets the color of the lines that separate the inside and outside of the  	indicator when cleared. +*--line-caps-lock-color* <rrggbb[aa]> +	Sets the color of the line between the inside and ring when Caps Lock +	is active. +  *--line-ver-color* <rrggbb[aa]>  	Sets the color of the lines that separate the inside and outside of the  	indicator when verifying. @@ -114,6 +133,9 @@ Locks your Wayland session.  *--ring-clear-color* <rrggbb[aa]>  	Sets the color of the outside of the indicator when cleared. +*--ring-caps-lock-color* <rrggbb[aa]> +	Sets the color of the ring of the indicator when Caps Lock is active. +  *--ring-ver-color* <rrggbb[aa]>  	Sets the color of the outside of the indicator when verifying. @@ -129,6 +151,9 @@ Locks your Wayland session.  *--text-clear-color* <rrggbb[aa]>  	Sets the color of the text inside the indicator when cleared. +*--text-caps-lock-color* <rrggbb[aa]> +	Sets the color of the text when Caps Lock is active. +  *--text-ver-color* <rrggbb[aa]>  	Sets the color of the text inside the indicator when verifying. | 
