From f1f239e970d87d8b4b46a4717001429c285f733e Mon Sep 17 00:00:00 2001 From: Matthew Fry Date: Thu, 5 Oct 2017 19:25:07 -0600 Subject: [PATCH 1/3] Added a ring width to customize the width of the ring --- i3lock.c | 15 +++++++++++++++ unlock_indicator.c | 10 ++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/i3lock.c b/i3lock.c index b9502c3..4615bb3 100644 --- a/i3lock.c +++ b/i3lock.c @@ -104,6 +104,7 @@ double date_size = 14.0; double text_size = 28.0; double modifier_size = 14.0; double circle_radius = 90.0; +double ring_width = 7.0; char* verif_text = "verifying…"; char* wrong_text = "wrong!"; @@ -947,6 +948,7 @@ int main(int argc, char *argv[]) { {"textsize", required_argument, NULL, 0}, {"modsize", required_argument, NULL, 0}, {"radius", required_argument, NULL, 0}, + {"ring-width", required_argument, NULL, 0}, {NULL, no_argument, NULL, 0}}; @@ -1289,6 +1291,19 @@ int main(int argc, char *argv[]) { circle_radius = 90.0; } } + else if (strcmp(longopts[longoptind].name, "ring-width") == 0) { + char *arg = optarg; + double new_width = 0; + if (sscanf(arg, "%lf", &new_width) != 1) + errx(1, "ring-width must be a number\n"); + if (new_width < 1) { + fprintf(stderr, "ring-width must be a positive integer; ignoring...\n"); + } + else { + ring_width = new_width; + } + } + break; case 'f': show_failed_attempts = true; diff --git a/unlock_indicator.c b/unlock_indicator.c index e81d2bd..12ac2c6 100644 --- a/unlock_indicator.c +++ b/unlock_indicator.c @@ -26,10 +26,12 @@ #include extern double circle_radius; +extern double ring_width; #define BUTTON_RADIUS (circle_radius) -#define BUTTON_SPACE (BUTTON_RADIUS + 5) -#define BUTTON_CENTER (BUTTON_RADIUS + 5) +#define RING_WIDTH (ring_width) +#define BUTTON_SPACE (BUTTON_RADIUS + RING_WIDTH) +#define BUTTON_CENTER (BUTTON_RADIUS + RING_WIDTH) #define BUTTON_DIAMETER (2 * BUTTON_SPACE) #define CLOCK_WIDTH 400 #define CLOCK_HEIGHT 200 @@ -324,7 +326,7 @@ xcb_pixmap_t draw_image(uint32_t *resolution) { (unlock_state >= STATE_KEY_PRESSED || auth_state > STATE_AUTH_IDLE || show_indicator)) { cairo_scale(ctx, scaling_factor(), scaling_factor()); /* Draw a (centered) circle with transparent background. */ - cairo_set_line_width(ctx, 7.0); + cairo_set_line_width(ctx, RING_WIDTH); cairo_arc(ctx, BUTTON_CENTER /* x */, BUTTON_CENTER /* y */, @@ -465,7 +467,7 @@ xcb_pixmap_t draw_image(uint32_t *resolution) { * keypress. */ if (unlock_state == STATE_KEY_ACTIVE || unlock_state == STATE_BACKSPACE_ACTIVE) { - cairo_set_line_width(ctx, 7.0); + cairo_set_line_width(ctx, RING_WIDTH); cairo_new_sub_path(ctx); double highlight_start = (rand() % (int)(2 * M_PI * 100)) / 100.0; cairo_arc(ctx, From 5365016db30e057ec0db296d7252979598f80557 Mon Sep 17 00:00:00 2001 From: Matthew Fry Date: Fri, 6 Oct 2017 08:35:25 -0600 Subject: [PATCH 2/3] Added to the ring-width option to the readme. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c38a359..4fb3f79 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ Many little improvements have been made to i3lock over time: - `--textsize=28` -- font size for the status text - `--modsize=14` -- font size for the modifier keys listing - `--radius=90` -- the radius of the circle indicator + - `--ring-width=7` -- the width of the indicator ring - You can specify whether i3lock should bell upon a wrong password. From 554bb5f53db059a1bc873a2394237f3f1549d1be Mon Sep 17 00:00:00 2001 From: Matthew Fry Date: Mon, 9 Oct 2017 09:18:16 -0600 Subject: [PATCH 3/3] Fixed the calculations for BUTTON_CENTER and BUTTON_SPACE. --- unlock_indicator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unlock_indicator.c b/unlock_indicator.c index 12ac2c6..217a8a3 100644 --- a/unlock_indicator.c +++ b/unlock_indicator.c @@ -30,8 +30,8 @@ extern double ring_width; #define BUTTON_RADIUS (circle_radius) #define RING_WIDTH (ring_width) -#define BUTTON_SPACE (BUTTON_RADIUS + RING_WIDTH) -#define BUTTON_CENTER (BUTTON_RADIUS + RING_WIDTH) +#define BUTTON_SPACE (BUTTON_RADIUS + (RING_WIDTH / 2)) +#define BUTTON_CENTER (BUTTON_RADIUS + (RING_WIDTH / 2)) #define BUTTON_DIAMETER (2 * BUTTON_SPACE) #define CLOCK_WIDTH 400 #define CLOCK_HEIGHT 200