i3lock-color

The world's most popular non-default computer lockscreen.
Index Commits Files Refs README LICENSE
commit 933c3b80aefcc953a6a9ab371e9c84fda1de2dde
parent fa0bf7bc4d9295b3e268a2def7d2d88597f3440a
Author: Thomas Osterland <t.osterland@web.de>
Date:   Thu, 22 Mar 2018 21:02:26 +0100

added functionality to randomly select images during slideshow

Diffstat:
Mi3lock.c | 5+++++
Munlock_indicator.c | 11++++++++---
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git 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
@@ -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;
         }