Adds option to show indicator even if idle

This commit is contained in:
Alexander Martin 2019-08-03 19:07:50 -06:00 committed by Brian Ashworth
parent 080e8356b7
commit 666ae950bc
6 changed files with 19 additions and 2 deletions

View File

@ -15,6 +15,7 @@ complete -c swaylock -s t -l tiling --description "Same as --scaling=tile."
complete -c swaylock -s c -l color --description "Turn the screen into the given color. If -i is used, this sets the background of the image into the given color. Defaults to white (ffffff), or transparent (00000000) if an image is in use." complete -c swaylock -s c -l color --description "Turn the screen into the given color. If -i is used, this sets the background of the image into the given color. Defaults to white (ffffff), or transparent (00000000) if an image is in use."
complete -c swaylock -l bs-hl-color --description 'Sets the color of backspace highlight segments.' complete -c swaylock -l bs-hl-color --description 'Sets the color of backspace highlight segments.'
complete -c swaylock -l font --description 'Sets the font of the text inside the indicator.' complete -c swaylock -l font --description 'Sets the font of the text inside the indicator.'
complete -c swaylock -l indicator-idle-visible --description 'Sets the indicator to show even if idle.'
complete -c swaylock -l indicator-radius --description 'Sets the radius of the indicator to radius pixels. Default: 50' complete -c swaylock -l indicator-radius --description 'Sets the radius of the indicator to radius pixels. Default: 50'
complete -c swaylock -l indicator-thickness --description 'Sets the thickness of the indicator to thickness pixels. Default: 10' complete -c swaylock -l indicator-thickness --description 'Sets the thickness of the indicator to thickness pixels. Default: 10'
complete -c swaylock -l inside-color --description 'Sets the color of the inside of the indicator when typing or idle.' complete -c swaylock -l inside-color --description 'Sets the color of the inside of the indicator when typing or idle.'

View File

@ -16,6 +16,7 @@ _arguments -s \
'(-v --version)'{-v,--version}'[Show the version number and quit]' \ '(-v --version)'{-v,--version}'[Show the version number and quit]' \
'(--bs-hl-color)'--bs-hl-color'[Sets the color of backspace highlights segments]:color:' \ '(--bs-hl-color)'--bs-hl-color'[Sets the color of backspace highlights segments]:color:' \
'(--font)'--font'[Sets the font of the text]:font:' \ '(--font)'--font'[Sets the font of the text]:font:' \
'(--indicator-idle-visible)'--indicator-idle-visible'[Sets the indicator to show even if idle]' \
'(--indicator-radius)'--indicator-radius'[Sets the indicator radius]:radius:' \ '(--indicator-radius)'--indicator-radius'[Sets the indicator radius]:radius:' \
'(--indicator-thickness)'--indicator-thickness'[Sets the indicator thickness]:thickness:' \ '(--indicator-thickness)'--indicator-thickness'[Sets the indicator thickness]:thickness:' \
'(--inside-color)'--inside-color'[Sets the color of the inside of the indicator]:color:' \ '(--inside-color)'--inside-color'[Sets the color of the inside of the indicator]:color:' \

View File

@ -58,6 +58,7 @@ struct swaylock_args {
bool hide_keyboard_layout; bool hide_keyboard_layout;
bool show_failed_attempts; bool show_failed_attempts;
bool daemonize; bool daemonize;
bool indicator_idle_visible;
}; };
struct swaylock_password { struct swaylock_password {

12
main.c
View File

@ -507,6 +507,7 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
LO_CAPS_LOCK_KEY_HL_COLOR, LO_CAPS_LOCK_KEY_HL_COLOR,
LO_FONT, LO_FONT,
LO_FONT_SIZE, LO_FONT_SIZE,
LO_IND_IDLE_VISIBLE,
LO_IND_RADIUS, LO_IND_RADIUS,
LO_IND_THICKNESS, LO_IND_THICKNESS,
LO_INSIDE_COLOR, LO_INSIDE_COLOR,
@ -561,6 +562,7 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
{"caps-lock-key-hl-color", required_argument, NULL, LO_CAPS_LOCK_KEY_HL_COLOR}, {"caps-lock-key-hl-color", required_argument, NULL, LO_CAPS_LOCK_KEY_HL_COLOR},
{"font", required_argument, NULL, LO_FONT}, {"font", required_argument, NULL, LO_FONT},
{"font-size", required_argument, NULL, LO_FONT_SIZE}, {"font-size", required_argument, NULL, LO_FONT_SIZE},
{"indicator-idle-visible", no_argument, NULL, LO_IND_IDLE_VISIBLE},
{"indicator-radius", required_argument, NULL, LO_IND_RADIUS}, {"indicator-radius", required_argument, NULL, LO_IND_RADIUS},
{"indicator-thickness", required_argument, NULL, LO_IND_THICKNESS}, {"indicator-thickness", required_argument, NULL, LO_IND_THICKNESS},
{"inside-color", required_argument, NULL, LO_INSIDE_COLOR}, {"inside-color", required_argument, NULL, LO_INSIDE_COLOR},
@ -638,6 +640,8 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
"Sets the font of the text.\n" "Sets the font of the text.\n"
" --font-size <size> " " --font-size <size> "
"Sets a fixed font size for the indicator text.\n" "Sets a fixed font size for the indicator text.\n"
" --indicator-idle-visible "
"Sets the indicator to show even if idle.\n"
" --indicator-radius <radius> " " --indicator-radius <radius> "
"Sets the indicator radius.\n" "Sets the indicator radius.\n"
" --indicator-thickness <thick> " " --indicator-thickness <thick> "
@ -826,6 +830,11 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
state->args.font_size = atoi(optarg); state->args.font_size = atoi(optarg);
} }
break; break;
case LO_IND_IDLE_VISIBLE:
if (state) {
state->args.indicator_idle_visible = true;
}
break;
case LO_IND_RADIUS: case LO_IND_RADIUS:
if (state) { if (state) {
state->args.radius = strtol(optarg, NULL, 0); state->args.radius = strtol(optarg, NULL, 0);
@ -1085,7 +1094,8 @@ int main(int argc, char **argv) {
.show_caps_lock_text = true, .show_caps_lock_text = true,
.show_keyboard_layout = false, .show_keyboard_layout = false,
.hide_keyboard_layout = false, .hide_keyboard_layout = false,
.show_failed_attempts = false .show_failed_attempts = false,
.indicator_idle_visible = false
}; };
wl_list_init(&state.images); wl_list_init(&state.images);
set_default_colors(&state.args.colors); set_default_colors(&state.args.colors);

View File

@ -116,7 +116,8 @@ void render_frame(struct swaylock_surface *surface) {
float type_indicator_border_thickness = float type_indicator_border_thickness =
TYPE_INDICATOR_BORDER_THICKNESS * surface->scale; TYPE_INDICATOR_BORDER_THICKNESS * surface->scale;
if (state->args.show_indicator && state->auth_state != AUTH_STATE_IDLE) { if (state->args.show_indicator && (state->auth_state != AUTH_STATE_IDLE ||
state->args.indicator_idle_visible)) {
// Draw circle // Draw circle
cairo_set_line_width(cairo, arc_thickness); cairo_set_line_width(cairo, arc_thickness);
cairo_arc(cairo, buffer_width / 2, buffer_diameter / 2, arc_radius, cairo_arc(cairo, buffer_width / 2, buffer_diameter / 2, arc_radius,

View File

@ -89,6 +89,9 @@ Locks your Wayland session.
*--font* <font> *--font* <font>
Sets the font of the text inside the indicator. Sets the font of the text inside the indicator.
*--indicator-idle-visible*
Sets the indicator to show even if idle.
*--indicator-radius* <radius> *--indicator-radius* <radius>
Sets the radius of the indicator to _radius_ pixels. The default value is Sets the radius of the indicator to _radius_ pixels. The default value is
50. 50.