From c9eee2646a2f9421803ae30169090d91485c0b12 Mon Sep 17 00:00:00 2001 From: Sidharth Rao Date: Sun, 25 Feb 2024 01:39:37 -0500 Subject: [PATCH] Help --- README.md | 7 ++++++- main.c | 6 ++++-- render.c | 7 ++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f3860e38..6895fe5f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ -# swaylock-effects +# swaylock-effects-battery + +Swaylock-effects-battery is a fork of [swaylock-effects](https://github.com/jirutka/swaylock-effects) +which adds a battery percentage display feature. Swaylock-effects is a fork of [swaylock](https://github.com/swaywm/swaylock) which adds built-in screenshots and image manipulation effects like blurring. @@ -15,6 +18,7 @@ which is no longer maintained. swaylock \ --screenshots \ + --battery \ --clock \ --indicator \ --indicator-radius 100 \ @@ -33,6 +37,7 @@ which is no longer maintained. The main new features compared to upstream swaylock are: +* `--battery` to display the battery percentage * `--screenshots` to use screenshots instead of an image on disk or a color * `--clock` to show date/time in the indicator * Use `--indicator` to make the indicator always active diff --git a/main.c b/main.c index 3e13c5fb..28b6cbdf 100644 --- a/main.c +++ b/main.c @@ -1147,6 +1147,8 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state, "Disable the unlock indicator.\n" " --indicator " "Always show the indicator.\n" + " --battery " + "Show the battery percentage.\n" " --clock " "Show time and date.\n" " --timestr " @@ -1864,7 +1866,7 @@ int main(int argc, char **argv) { .font = strdup("sans-serif"), .font_size = 0, .radius = 100, - .thickness = 10, + .thickness = 9, .indicator_x_position = 0, .indicator_y_position = 0, .override_indicator_x_position = false, @@ -1884,7 +1886,7 @@ int main(int argc, char **argv) { .indicator = false, .clock = false, .timestr = strdup("%T"), - .datestr = strdup("%x"), + .datestr = strdup("%a, %x"), .allow_fade = true, .password_grace_period = 0, diff --git a/render.c b/render.c index 3bc54b2d..5d35d21f 100644 --- a/render.c +++ b/render.c @@ -375,12 +375,13 @@ void render_frame(struct swaylock_surface *surface, char *battery_str) { /* Top */ + cairo_set_font_size(cairo, arc_radius / 4.0f); cairo_text_extents(cairo, text_l1, &extents_l1); cairo_font_extents(cairo, &fe_l1); x_l1 = (buffer_width / 2) - (extents_l1.width / 2 + extents_l1.x_bearing); y_l1 = (buffer_diameter / 2) + - (fe_l1.height / 2 - fe_l1.descent) - arc_radius / 10.0f; + (fe_l1.height / 2 - fe_l1.descent) - arc_radius / 8.0f; cairo_move_to(cairo, x_l1, y_l1); cairo_show_text(cairo, text_l1); @@ -389,13 +390,13 @@ void render_frame(struct swaylock_surface *surface, char *battery_str) { /* Bottom */ - cairo_set_font_size(cairo, arc_radius / 6.0f); + cairo_set_font_size(cairo, arc_radius / 6.5f); cairo_text_extents(cairo, text_l2, &extents_l2); cairo_font_extents(cairo, &fe_l2); x_l2 = (buffer_width / 2) - (extents_l2.width / 2 + extents_l2.x_bearing); y_l2 = (buffer_diameter / 2) + - (fe_l2.height / 2 - fe_l2.descent) + arc_radius / 3.5f; + (fe_l2.height / 2 - fe_l2.descent) + arc_radius / 5.0f; cairo_move_to(cairo, x_l2, y_l2); cairo_show_text(cairo, text_l2);