Browse Source

added functionality to randomly select images during slideshow

master
Thomas Osterland 7 years ago
parent
commit
933c3b80ae
  1. 5
      i3lock.c
  2. 11
      unlock_indicator.c

5
i3lock.c

@ -205,6 +205,7 @@ cairo_surface_t *blur_img = NULL;
cairo_surface_t *img_slideshow[256]; cairo_surface_t *img_slideshow[256];
int slideshow_image_count = 0; int slideshow_image_count = 0;
int slideshow_interval = 10; int slideshow_interval = 10;
bool slideshow_random_selection = false;
bool tile = false; bool tile = false;
bool ignore_empty_password = false; bool ignore_empty_password = false;
@ -1221,6 +1222,7 @@ int main(int argc, char *argv[]) {
/* slideshow options */ /* slideshow options */
{"slideshow-interval", required_argument, NULL, 903}, {"slideshow-interval", required_argument, NULL, 903},
{"slideshow-random-selection", no_argument, NULL, 904},
{NULL, no_argument, NULL, 0}}; {NULL, no_argument, NULL, 0}};
@ -1679,6 +1681,9 @@ int main(int argc, char *argv[]) {
slideshow_interval = 10; slideshow_interval = 10;
} }
break; break;
case 904:
slideshow_random_selection = true;
break;
case 999: case 999:
debug_mode = true; debug_mode = true;
break; break;

11
unlock_indicator.c

@ -62,6 +62,7 @@ extern cairo_surface_t *blur_img;
extern cairo_surface_t *img_slideshow[256]; extern cairo_surface_t *img_slideshow[256];
extern int slideshow_image_count; extern int slideshow_image_count;
extern int slideshow_interval; extern int slideshow_interval;
extern bool slideshow_random_selection;
unsigned long lastCheck; unsigned long lastCheck;
@ -693,10 +694,14 @@ xcb_pixmap_t draw_image(uint32_t *resolution) {
if (slideshow_image_count > 0) { if (slideshow_image_count > 0) {
unsigned long now = (unsigned long)time(NULL); unsigned long now = (unsigned long)time(NULL);
if (img == NULL || now - lastCheck >= slideshow_interval) { 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) { if (current_slideshow_index >= slideshow_image_count) {
current_slideshow_index = 0; current_slideshow_index = 0;
}
} }
lastCheck = now; lastCheck = now;
} }

Loading…
Cancel
Save