summaryrefslogtreecommitdiff
path: root/unlock_indicator.c
diff options
context:
space:
mode:
authorSimeon Simeonov2020-12-10 23:57:33 +0100
committerSimeon Simeonov2020-12-10 23:57:33 +0100
commitb16438a23b237aa44fe9358a0b8954888bf81ea2 (patch)
tree9e0fcb3e8f3d4b1707bd702f2bf4429299d1e2e3 /unlock_indicator.c
parent12a06184e733554bafc76e643b49067fcd758fc0 (diff)
Add support for counting to a specific calendar time (absolute time)
Diffstat (limited to 'unlock_indicator.c')
-rw-r--r--unlock_indicator.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/unlock_indicator.c b/unlock_indicator.c
index 73320cb..8f69972 100644
--- a/unlock_indicator.c
+++ b/unlock_indicator.c
@@ -58,12 +58,15 @@ extern bool debug_mode;
58 58
59#ifdef EXTRAS 59#ifdef EXTRAS
60/* timekeeping */ 60/* timekeeping */
61#define I3LOCK_COUNT_UNTIL_BUFFER 128
62char count_until_str[I3LOCK_COUNT_UNTIL_BUFFER];
61time_t now; 63time_t now;
62struct tm *brokentime; 64struct tm *brokentime;
63/* enable the digital clock */ 65/* enable the digital clock */
64extern bool digital_clock; 66extern bool digital_clock;
65extern bool led_clock; 67extern bool led_clock;
66extern bool elapsed_time; 68extern bool elapsed_time;
69extern int count_until;
67extern i3lock_digital_clock_t i3lock_digital_clock; 70extern i3lock_digital_clock_t i3lock_digital_clock;
68extern i3lock_elapsed_time_t i3lock_elapsed_time; 71extern i3lock_elapsed_time_t i3lock_elapsed_time;
69extern i3lock_led_clock_t i3lock_led_clock; 72extern i3lock_led_clock_t i3lock_led_clock;
@@ -359,17 +362,30 @@ void draw_image(xcb_pixmap_t bg_pixmap, uint32_t *resolution) {
359 resolution, 362 resolution,
360 brokentime); 363 brokentime);
361 } 364 }
362 /* elapsed time or display text */ 365 /* elapsed time or counter with display text or only display text */
363 if (elapsed_time) { 366 if (elapsed_time) {
364 i3lock_draw_elapsed_time(xcb_ctx, 367 i3lock_draw_elapsed_time(xcb_ctx,
365 &i3lock_elapsed_time, 368 &i3lock_elapsed_time,
366 resolution, 369 resolution,
367 &now); 370 &now);
368 } else if (display_text != NULL) { 371 } else if (display_text != NULL) {
369 i3lock_draw_string(xcb_ctx, 372 if (count_until) {
370 display_text, 373 if (i3lock_format_elapsed_time(
371 &i3lock_elapsed_time, 374 count_until_str,
372 resolution); 375 display_text,
376 I3LOCK_COUNT_UNTIL_BUFFER,
377 count_until - (int) now) != NULL) {
378 i3lock_draw_string(xcb_ctx,
379 count_until_str,
380 &i3lock_elapsed_time,
381 resolution);
382 }
383 } else {
384 i3lock_draw_string(xcb_ctx,
385 display_text,
386 &i3lock_elapsed_time,
387 resolution);
388 }
373 } 389 }
374#endif 390#endif
375 if (xr_screens > 0) { 391 if (xr_screens > 0) {