Skip to content

Commit

Permalink
Help
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthmrao committed Feb 25, 2024
1 parent 4fb870a commit c9eee26
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -15,6 +18,7 @@ which is no longer maintained.

swaylock \
--screenshots \
--battery \
--clock \
--indicator \
--indicator-radius 100 \
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <format> "
Expand Down Expand Up @@ -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,
Expand All @@ -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,

Expand Down
7 changes: 4 additions & 3 deletions render.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit c9eee26

Please sign in to comment.