diff options
Diffstat (limited to 'unlock_indicator.c')
| -rw-r--r-- | unlock_indicator.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/unlock_indicator.c b/unlock_indicator.c index 33b9406..2baf738 100644 --- a/unlock_indicator.c +++ b/unlock_indicator.c | |||
| @@ -59,20 +59,21 @@ extern bool debug_mode; | |||
| 59 | 59 | ||
| 60 | #ifdef EXTRAS | 60 | #ifdef EXTRAS |
| 61 | /* timekeeping */ | 61 | /* timekeeping */ |
| 62 | #define I3LOCK_COUNT_UNTIL_BUFFER 128 | 62 | #define I3LOCK_DISPLAY_TEXT_BUFFER_SIZE 128 |
| 63 | char count_until_str[I3LOCK_COUNT_UNTIL_BUFFER]; | 63 | char display_text[I3LOCK_DISPLAY_TEXT_BUFFER_SIZE]; |
| 64 | time_t now; | 64 | time_t now; |
| 65 | struct tm *brokentime; | 65 | struct tm *brokentime; |
| 66 | /* enable the digital clock */ | 66 | /* enable the digital clock */ |
| 67 | extern bool digital_clock; | 67 | extern bool digital_clock; |
| 68 | extern bool led_clock; | 68 | extern bool led_clock; |
| 69 | extern bool elapsed_time; | 69 | extern bool elapsed_time; |
| 70 | extern bool unix_time; | ||
| 70 | extern int count_until; | 71 | extern int count_until; |
| 71 | extern i3lock_digital_clock_t i3lock_digital_clock; | 72 | extern i3lock_digital_clock_t i3lock_digital_clock; |
| 72 | extern i3lock_elapsed_time_t i3lock_elapsed_time; | 73 | extern i3lock_elapsed_time_t i3lock_elapsed_time; |
| 73 | extern i3lock_led_clock_t i3lock_led_clock; | 74 | extern i3lock_led_clock_t i3lock_led_clock; |
| 74 | /* display text */ | 75 | /* display text */ |
| 75 | extern char *display_text; | 76 | extern char *display_text_template; |
| 76 | #endif | 77 | #endif |
| 77 | 78 | ||
| 78 | /* The current position in the input buffer. Useful to determine if any | 79 | /* The current position in the input buffer. Useful to determine if any |
| @@ -438,27 +439,37 @@ void draw_image(xcb_pixmap_t bg_pixmap, uint32_t *resolution) { | |||
| 438 | resolution, | 439 | resolution, |
| 439 | brokentime); | 440 | brokentime); |
| 440 | } | 441 | } |
| 441 | /* elapsed time or counter with display text or only display text */ | 442 | |
| 443 | /* elapsed time, counter with display text, UNIX time or display text */ | ||
| 442 | if (elapsed_time) { | 444 | if (elapsed_time) { |
| 443 | i3lock_draw_elapsed_time(xcb_ctx, | 445 | i3lock_draw_elapsed_time(xcb_ctx, |
| 444 | &i3lock_elapsed_time, | 446 | &i3lock_elapsed_time, |
| 445 | resolution, | 447 | resolution, |
| 446 | &now); | 448 | &now); |
| 447 | } else if (display_text != NULL) { | 449 | } else if (unix_time) { |
| 450 | snprintf(display_text, | ||
| 451 | I3LOCK_DISPLAY_TEXT_BUFFER_SIZE, | ||
| 452 | "%d", (int) now); | ||
| 453 | i3lock_draw_string(xcb_ctx, | ||
| 454 | display_text, | ||
| 455 | &i3lock_elapsed_time, | ||
| 456 | resolution); | ||
| 457 | } else if (display_text_template != NULL) { | ||
| 458 | /* display text */ | ||
| 448 | if (count_until) { | 459 | if (count_until) { |
| 449 | if (i3lock_format_elapsed_time( | 460 | if (i3lock_format_elapsed_time( |
| 450 | count_until_str, | ||
| 451 | display_text, | 461 | display_text, |
| 452 | I3LOCK_COUNT_UNTIL_BUFFER, | 462 | display_text_template, |
| 463 | I3LOCK_DISPLAY_TEXT_BUFFER_SIZE, | ||
| 453 | count_until - (int) now) != NULL) { | 464 | count_until - (int) now) != NULL) { |
| 454 | i3lock_draw_string(xcb_ctx, | 465 | i3lock_draw_string(xcb_ctx, |
| 455 | count_until_str, | 466 | display_text, |
| 456 | &i3lock_elapsed_time, | 467 | &i3lock_elapsed_time, |
| 457 | resolution); | 468 | resolution); |
| 458 | } | 469 | } |
| 459 | } else { | 470 | } else { |
| 460 | i3lock_draw_string(xcb_ctx, | 471 | i3lock_draw_string(xcb_ctx, |
| 461 | display_text, | 472 | display_text_template, |
| 462 | &i3lock_elapsed_time, | 473 | &i3lock_elapsed_time, |
| 463 | resolution); | 474 | resolution); |
| 464 | } | 475 | } |
