diff --git a/i3lock.c b/i3lock.c index 2d1cad2..1138360 100644 --- a/i3lock.c +++ b/i3lock.c @@ -205,6 +205,7 @@ cairo_surface_t *blur_img = NULL; cairo_surface_t *img_slideshow[256]; int slideshow_image_count = 0; int slideshow_interval = 10; +bool slideshow_random_selection = false; bool tile = false; bool ignore_empty_password = false; @@ -1221,6 +1222,7 @@ int main(int argc, char *argv[]) { /* slideshow options */ {"slideshow-interval", required_argument, NULL, 903}, + {"slideshow-random-selection", no_argument, NULL, 904}, {NULL, no_argument, NULL, 0}}; @@ -1679,6 +1681,9 @@ int main(int argc, char *argv[]) { slideshow_interval = 10; } break; + case 904: + slideshow_random_selection = true; + break; case 999: debug_mode = true; break; diff --git a/unlock_indicator.c b/unlock_indicator.c index c8bcb5a..f4fe176 100644 --- a/unlock_indicator.c +++ b/unlock_indicator.c @@ -62,6 +62,7 @@ extern cairo_surface_t *blur_img; extern cairo_surface_t *img_slideshow[256]; extern int slideshow_image_count; extern int slideshow_interval; +extern bool slideshow_random_selection; unsigned long lastCheck; @@ -693,10 +694,14 @@ xcb_pixmap_t draw_image(uint32_t *resolution) { if (slideshow_image_count > 0) { unsigned long now = (unsigned long)time(NULL); if (img == NULL || now - lastCheck >= slideshow_interval) { - img = img_slideshow[current_slideshow_index++]; + if (slideshow_random_selection) { + img = img_slideshow[rand() % slideshow_image_count]; + } else { + img = img_slideshow[current_slideshow_index++]; - if (current_slideshow_index >= slideshow_image_count) { - current_slideshow_index = 0; + if (current_slideshow_index >= slideshow_image_count) { + current_slideshow_index = 0; + } } lastCheck = now; }