From f28df019b51cc7a3ad308f1bf311adcf32a515a1 Mon Sep 17 00:00:00 2001 From: metafates Date: Tue, 7 Feb 2023 14:41:38 +0300 Subject: [PATCH 1/2] feat: add `--font-bold` boolean argument --- completions/bash/swaylock | 1 + completions/fish/swaylock.fish | 1 + completions/zsh/_swaylock | 1 + include/swaylock.h | 1 + main.c | 2 ++ render.c | 2 +- swaylock.1.scd | 3 +++ 7 files changed, 10 insertions(+), 1 deletion(-) diff --git a/completions/bash/swaylock b/completions/bash/swaylock index 4985922af..a5322fadb 100644 --- a/completions/bash/swaylock +++ b/completions/bash/swaylock @@ -37,6 +37,7 @@ _swaylock() --disable-caps-lock-text --font --font-size + --font-bold --help --hide-keyboard-layout --ignore-empty-password diff --git a/completions/fish/swaylock.fish b/completions/fish/swaylock.fish index 41416a393..db3e725f7 100644 --- a/completions/fish/swaylock.fish +++ b/completions/fish/swaylock.fish @@ -10,6 +10,7 @@ complete -c swaylock -l debug -s d --description "Enable debugg complete -c swaylock -l disable-caps-lock-text -s L --description "Disable the Caps Lock text." complete -c swaylock -l font --description "Sets the font of the text." complete -c swaylock -l font-size --description "Sets a fixed font size for the indicator text." +complete -c swaylock -l font-bold --description "Sets a fixed font size for the indicator text" complete -c swaylock -l help -s h --description "Show help message and quit." complete -c swaylock -l hide-keyboard-layout -s K --description "Hide the current xkb layout while typing." complete -c swaylock -l ignore-empty-password -s e --description "When an empty password is provided, do not validate it." diff --git a/completions/zsh/_swaylock b/completions/zsh/_swaylock index 9e9f78866..1168f9322 100644 --- a/completions/zsh/_swaylock +++ b/completions/zsh/_swaylock @@ -14,6 +14,7 @@ _arguments -s \ '(--disable-caps-lock-text -L)'{--disable-caps-lock-text,-L}'[Disable the Caps Lock text]' \ '(--font)'--font'[Sets the font of the text]:font:' \ '(--font-size)'--font-size'[Sets a fixed font size for the indicator text]' \ + '(--font-bold)'--font-bold'[Use bold font weight for the indicator text]' \ '(--help -h)'{--help,-h}'[Show help message and quit]' \ '(--hide-keyboard-layout -K)'{--hide-keyboard-layout,-K}'[Hide the current xkb layout while typing]' \ '(--ignore-empty-password -e)'{--ignore-empty-password,-e}'[When an empty password is provided, do not validate it]' \ diff --git a/include/swaylock.h b/include/swaylock.h index 9de8ab688..61a01777c 100644 --- a/include/swaylock.h +++ b/include/swaylock.h @@ -47,6 +47,7 @@ struct swaylock_args { enum background_mode mode; char *font; uint32_t font_size; + bool font_bold; uint32_t radius; uint32_t thickness; uint32_t indicator_x_position; diff --git a/main.c b/main.c index 26d30a52e..6f2b7b768 100644 --- a/main.c +++ b/main.c @@ -485,6 +485,7 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state, LO_CAPS_LOCK_KEY_HL_COLOR, LO_FONT, LO_FONT_SIZE, + LO_FONT_BOLD, LO_IND_IDLE_VISIBLE, LO_IND_RADIUS, LO_IND_X_POSITION, @@ -542,6 +543,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}, {"font", required_argument, NULL, LO_FONT}, {"font-size", required_argument, NULL, LO_FONT_SIZE}, + {"font-bold", no_argument, NULL, LO_FONT_BOLD}, {"indicator-idle-visible", no_argument, NULL, LO_IND_IDLE_VISIBLE}, {"indicator-radius", required_argument, NULL, LO_IND_RADIUS}, {"indicator-thickness", required_argument, NULL, LO_IND_THICKNESS}, diff --git a/render.c b/render.c index 3ce7a8075..e5fcc5b8a 100644 --- a/render.c +++ b/render.c @@ -77,7 +77,7 @@ static void configure_font_drawing(cairo_t *cairo, struct swaylock_state *state, cairo_set_font_options(cairo, fo); cairo_select_font_face(cairo, state->args.font, - CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); + CAIRO_FONT_SLANT_NORMAL, state->args.font_bold ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL); if (state->args.font_size > 0) { cairo_set_font_size(cairo, state->args.font_size); } else { diff --git a/swaylock.1.scd b/swaylock.1.scd index 61691eb49..0dcf1e8ef 100644 --- a/swaylock.1.scd +++ b/swaylock.1.scd @@ -92,6 +92,9 @@ Locks your Wayland session. *--font-size* Sets a fixed font size for the indicator text. +*--font-bold* + Use bold font weight for the indicator text + *--indicator-idle-visible* Sets the indicator to show even if idle. From e588f9e74d2e594c261646525f74476c3f7baeb6 Mon Sep 17 00:00:00 2001 From: Vadim Date: Wed, 8 Feb 2023 11:17:16 +0300 Subject: [PATCH 2/2] fix: fish completion description --- completions/fish/swaylock.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/completions/fish/swaylock.fish b/completions/fish/swaylock.fish index db3e725f7..91bd4506c 100644 --- a/completions/fish/swaylock.fish +++ b/completions/fish/swaylock.fish @@ -10,7 +10,7 @@ complete -c swaylock -l debug -s d --description "Enable debugg complete -c swaylock -l disable-caps-lock-text -s L --description "Disable the Caps Lock text." complete -c swaylock -l font --description "Sets the font of the text." complete -c swaylock -l font-size --description "Sets a fixed font size for the indicator text." -complete -c swaylock -l font-bold --description "Sets a fixed font size for the indicator text" +complete -c swaylock -l font-bold --description "Use bold font weight for the indicator text" complete -c swaylock -l help -s h --description "Show help message and quit." complete -c swaylock -l hide-keyboard-layout -s K --description "Hide the current xkb layout while typing." complete -c swaylock -l ignore-empty-password -s e --description "When an empty password is provided, do not validate it."