diff options
| -rw-r--r-- | CHANGELOG | 7 | ||||
| -rw-r--r-- | extras.c | 84 | ||||
| -rw-r--r-- | i3lock-extended.1 | 21 | ||||
| -rw-r--r-- | i3lock.c | 63 | ||||
| -rw-r--r-- | include/extras.h | 2 | ||||
| -rw-r--r-- | meson.build | 2 | ||||
| -rw-r--r-- | unlock_indicator.c | 29 |
7 files changed, 124 insertions, 84 deletions
| @@ -1,3 +1,10 @@ | |||
| 1 | 2024-11-24 i3lock-extended 3.2.15 | ||
| 2 | |||
| 3 | • Fetch and sync upstream master | ||
| 4 | • Add support for UNIX time (seconds since Epoch) | ||
| 5 | • Rename elapsed-time-* options to display-text-* | ||
| 6 | |||
| 7 | |||
| 1 | 2024-04-12 i3lock-extended 2.2.15 | 8 | 2024-04-12 i3lock-extended 2.2.15 |
| 2 | 9 | ||
| 3 | • Fetch and sync with i3lock 2.15 | 10 | • Fetch and sync with i3lock 2.15 |
| @@ -46,11 +46,11 @@ static void i3lock_color_to_array(double *rgb16, const char *color) { | |||
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | 48 | ||
| 49 | static void i3clock_fetch_digital_clock_xy(int *x, | 49 | static void i3lock_fetch_digital_clock_xy(int *x, |
| 50 | int *y, | 50 | int *y, |
| 51 | const i3lock_digital_clock_t *dc, | 51 | const i3lock_digital_clock_t *dc, |
| 52 | const uint32_t *resolution, | 52 | const uint32_t *resolution, |
| 53 | int text_length) { | 53 | int text_length) { |
| 54 | 54 | ||
| 55 | /* x */ | 55 | /* x */ |
| 56 | if (dc->horizontal_alignment == I3LOCK_ALIGN_CENTER) { | 56 | if (dc->horizontal_alignment == I3LOCK_ALIGN_CENTER) { |
| @@ -75,7 +75,7 @@ static void i3clock_fetch_digital_clock_xy(int *x, | |||
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | 77 | ||
| 78 | static void i3clock_fetch_led_clock_xy(int *x, | 78 | static void i3lock_fetch_led_clock_xy(int *x, |
| 79 | int *y, | 79 | int *y, |
| 80 | const i3lock_led_clock_t *lc, | 80 | const i3lock_led_clock_t *lc, |
| 81 | const uint32_t *resolution) { | 81 | const uint32_t *resolution) { |
| @@ -211,11 +211,11 @@ void i3lock_draw_digital_clock(cairo_t *cr, | |||
| 211 | for (screen = 0; screen < xr_screens; ++screen) { | 211 | for (screen = 0; screen < xr_screens; ++screen) { |
| 212 | screen_resolution[0] = xr_resolutions[screen].width; | 212 | screen_resolution[0] = xr_resolutions[screen].width; |
| 213 | screen_resolution[1] = xr_resolutions[screen].height; | 213 | screen_resolution[1] = xr_resolutions[screen].height; |
| 214 | i3clock_fetch_digital_clock_xy(&x, | 214 | i3lock_fetch_digital_clock_xy(&x, |
| 215 | &y, | 215 | &y, |
| 216 | dc, | 216 | dc, |
| 217 | screen_resolution, | 217 | screen_resolution, |
| 218 | strlen(current_time_str)); | 218 | strlen(current_time_str)); |
| 219 | cairo_move_to(cr, | 219 | cairo_move_to(cr, |
| 220 | x + xr_resolutions[screen].x, | 220 | x + xr_resolutions[screen].x, |
| 221 | y + xr_resolutions[screen].y); | 221 | y + xr_resolutions[screen].y); |
| @@ -224,11 +224,11 @@ void i3lock_draw_digital_clock(cairo_t *cr, | |||
| 224 | return; | 224 | return; |
| 225 | } | 225 | } |
| 226 | 226 | ||
| 227 | i3clock_fetch_digital_clock_xy(&x, | 227 | i3lock_fetch_digital_clock_xy(&x, |
| 228 | &y, | 228 | &y, |
| 229 | dc, | 229 | dc, |
| 230 | resolution, | 230 | resolution, |
| 231 | strlen(current_time_str)); | 231 | strlen(current_time_str)); |
| 232 | /* printf("%dx%d\n", *resolution, *(resolution + 1)); */ | 232 | /* printf("%dx%d\n", *resolution, *(resolution + 1)); */ |
| 233 | cairo_move_to(cr, x, y); | 233 | cairo_move_to(cr, x, y); |
| 234 | cairo_show_text(cr, current_time_str); | 234 | cairo_show_text(cr, current_time_str); |
| @@ -244,7 +244,7 @@ void i3lock_draw_string(cairo_t *cr, | |||
| 244 | int x, y; | 244 | int x, y; |
| 245 | 245 | ||
| 246 | /* create a dummy i3lock_digital_clock_t structure in order to reuse | 246 | /* create a dummy i3lock_digital_clock_t structure in order to reuse |
| 247 | i3clock_fetch_digital_clock_xy */ | 247 | i3lock_fetch_digital_clock_xy */ |
| 248 | i3lock_digital_clock_t dc = {et->text_size, | 248 | i3lock_digital_clock_t dc = {et->text_size, |
| 249 | "", | 249 | "", |
| 250 | "", | 250 | "", |
| @@ -263,11 +263,11 @@ void i3lock_draw_string(cairo_t *cr, | |||
| 263 | for (screen = 0; screen < xr_screens; ++screen) { | 263 | for (screen = 0; screen < xr_screens; ++screen) { |
| 264 | screen_resolution[0] = xr_resolutions[screen].width; | 264 | screen_resolution[0] = xr_resolutions[screen].width; |
| 265 | screen_resolution[1] = xr_resolutions[screen].height; | 265 | screen_resolution[1] = xr_resolutions[screen].height; |
| 266 | i3clock_fetch_digital_clock_xy(&x, | 266 | i3lock_fetch_digital_clock_xy(&x, |
| 267 | &y, | 267 | &y, |
| 268 | &dc, | 268 | &dc, |
| 269 | screen_resolution, | 269 | screen_resolution, |
| 270 | strlen(formatted_string)); | 270 | strlen(formatted_string)); |
| 271 | cairo_move_to(cr, | 271 | cairo_move_to(cr, |
| 272 | x + xr_resolutions[screen].x, | 272 | x + xr_resolutions[screen].x, |
| 273 | y + xr_resolutions[screen].y); | 273 | y + xr_resolutions[screen].y); |
| @@ -276,11 +276,11 @@ void i3lock_draw_string(cairo_t *cr, | |||
| 276 | return; | 276 | return; |
| 277 | } | 277 | } |
| 278 | 278 | ||
| 279 | i3clock_fetch_digital_clock_xy(&x, | 279 | i3lock_fetch_digital_clock_xy(&x, |
| 280 | &y, | 280 | &y, |
| 281 | &dc, | 281 | &dc, |
| 282 | resolution, | 282 | resolution, |
| 283 | strlen(formatted_string)); | 283 | strlen(formatted_string)); |
| 284 | /* printf("%dx%d\n", *resolution, *(resolution + 1)); */ | 284 | /* printf("%dx%d\n", *resolution, *(resolution + 1)); */ |
| 285 | cairo_move_to(cr, x, y); | 285 | cairo_move_to(cr, x, y); |
| 286 | cairo_show_text(cr, formatted_string); | 286 | cairo_show_text(cr, formatted_string); |
| @@ -297,7 +297,7 @@ void i3lock_draw_elapsed_time(cairo_t *cr, | |||
| 297 | int x, y, seconds, minutes, hours, diff_seconds; | 297 | int x, y, seconds, minutes, hours, diff_seconds; |
| 298 | 298 | ||
| 299 | /* create a dummy i3lock_digital_clock_t structure in ordet to reuse | 299 | /* create a dummy i3lock_digital_clock_t structure in ordet to reuse |
| 300 | i3clock_fetch_digital_clock_xy */ | 300 | i3lock_fetch_digital_clock_xy */ |
| 301 | i3lock_digital_clock_t dc = {et->text_size, | 301 | i3lock_digital_clock_t dc = {et->text_size, |
| 302 | "", | 302 | "", |
| 303 | "", | 303 | "", |
| @@ -339,11 +339,11 @@ void i3lock_draw_elapsed_time(cairo_t *cr, | |||
| 339 | for (screen = 0; screen < xr_screens; ++screen) { | 339 | for (screen = 0; screen < xr_screens; ++screen) { |
| 340 | screen_resolution[0] = xr_resolutions[screen].width; | 340 | screen_resolution[0] = xr_resolutions[screen].width; |
| 341 | screen_resolution[1] = xr_resolutions[screen].height; | 341 | screen_resolution[1] = xr_resolutions[screen].height; |
| 342 | i3clock_fetch_digital_clock_xy(&x, | 342 | i3lock_fetch_digital_clock_xy(&x, |
| 343 | &y, | 343 | &y, |
| 344 | &dc, | 344 | &dc, |
| 345 | screen_resolution, | 345 | screen_resolution, |
| 346 | strlen(elapsed_time_str)); | 346 | strlen(elapsed_time_str)); |
| 347 | cairo_move_to(cr, | 347 | cairo_move_to(cr, |
| 348 | x + xr_resolutions[screen].x, | 348 | x + xr_resolutions[screen].x, |
| 349 | y + xr_resolutions[screen].y); | 349 | y + xr_resolutions[screen].y); |
| @@ -352,11 +352,11 @@ void i3lock_draw_elapsed_time(cairo_t *cr, | |||
| 352 | return; | 352 | return; |
| 353 | } | 353 | } |
| 354 | 354 | ||
| 355 | i3clock_fetch_digital_clock_xy(&x, | 355 | i3lock_fetch_digital_clock_xy(&x, |
| 356 | &y, | 356 | &y, |
| 357 | &dc, | 357 | &dc, |
| 358 | resolution, | 358 | resolution, |
| 359 | strlen(elapsed_time_str)); | 359 | strlen(elapsed_time_str)); |
| 360 | /* printf("%dx%d\n", *resolution, *(resolution + 1)); */ | 360 | /* printf("%dx%d\n", *resolution, *(resolution + 1)); */ |
| 361 | cairo_move_to(cr, x, y); | 361 | cairo_move_to(cr, x, y); |
| 362 | cairo_show_text(cr, elapsed_time_str); | 362 | cairo_show_text(cr, elapsed_time_str); |
| @@ -379,10 +379,10 @@ void i3lock_draw_led_clock(cairo_t *cr, | |||
| 379 | screen_resolution[1] = xr_resolutions[screen].height; | 379 | screen_resolution[1] = xr_resolutions[screen].height; |
| 380 | side_length = xr_resolutions[screen].height / I3LOCK_SCALE_LED_SPACING; | 380 | side_length = xr_resolutions[screen].height / I3LOCK_SCALE_LED_SPACING; |
| 381 | space_length = xr_resolutions[screen].height / I3LOCK_SCALE_LED_LENGTH; | 381 | space_length = xr_resolutions[screen].height / I3LOCK_SCALE_LED_LENGTH; |
| 382 | i3clock_fetch_led_clock_xy(&base_x, | 382 | i3lock_fetch_led_clock_xy(&base_x, |
| 383 | &base_y, | 383 | &base_y, |
| 384 | lc, | 384 | lc, |
| 385 | screen_resolution); | 385 | screen_resolution); |
| 386 | base_x += xr_resolutions[screen].x; | 386 | base_x += xr_resolutions[screen].x; |
| 387 | base_y += xr_resolutions[screen].y; | 387 | base_y += xr_resolutions[screen].y; |
| 388 | base_x_h = base_x + space_length / 2 + side_length / 2; | 388 | base_x_h = base_x + space_length / 2 + side_length / 2; |
diff --git a/i3lock-extended.1 b/i3lock-extended.1 index 5a15f42..a5aae27 100644 --- a/i3lock-extended.1 +++ b/i3lock-extended.1 | |||
| @@ -49,6 +49,7 @@ i3lock\-extended \- improved screen locker | |||
| 49 | .RB [\|\-T | 49 | .RB [\|\-T |
| 50 | .IR template \|] | 50 | .IR template \|] |
| 51 | .RB [\|\-t\|] | 51 | .RB [\|\-t\|] |
| 52 | .RB [\|\-U\|] | ||
| 52 | .RB [\|\-u\|] | 53 | .RB [\|\-u\|] |
| 53 | .RB [\|\-v\|] | 54 | .RB [\|\-v\|] |
| 54 | .RB [\|\-W | 55 | .RB [\|\-W |
| @@ -98,6 +99,8 @@ Elapsed time since activation | |||
| 98 | Display-text | 99 | Display-text |
| 99 | .IP \[bu] | 100 | .IP \[bu] |
| 100 | Count broken-down time until a specific calendar time (absolute time) | 101 | Count broken-down time until a specific calendar time (absolute time) |
| 102 | .IP \[bu] | ||
| 103 | UNIX time (seconds since Epoch) | ||
| 101 | 104 | ||
| 102 | .SH OPTIONS | 105 | .SH OPTIONS |
| 103 | .TP | 106 | .TP |
| @@ -191,8 +194,8 @@ displays a hardcoded Windows-Pointer (thus enabling you to mess with your | |||
| 191 | friends by using a screenshot of a Windows desktop as a locking-screen). | 194 | friends by using a screenshot of a Windows desktop as a locking-screen). |
| 192 | 195 | ||
| 193 | .TP | 196 | .TP |
| 194 | .BI \-R\ rrggbb \fR,\ \fB\-\-elapsed\-time\-color= rrggbb | 197 | .BI \-R\ rrggbb \fR,\ \fB\-\-display\-text\-color= rrggbb |
| 195 | The color of the elapsed time (text). Default: 000000 (black). | 198 | The color of the display text, elapsed time and UNIX time (text). Default: 000000 (black). |
| 196 | 199 | ||
| 197 | .TP | 200 | .TP |
| 198 | .BI \-r\ rate \fR,\ \fB\-\-refresh\-rate= rate | 201 | .BI \-r\ rate \fR,\ \fB\-\-refresh\-rate= rate |
| @@ -227,7 +230,7 @@ support each one explicitly. | |||
| 227 | 230 | ||
| 228 | .TP | 231 | .TP |
| 229 | .BI \-S\ size \fR,\ \fB\-\-text\-size= size | 232 | .BI \-S\ size \fR,\ \fB\-\-text\-size= size |
| 230 | The text size for elapsed time, digital clock and display-text. Default: 28. | 233 | The text size for digital clock, display text, elapsed time and UNIX time. Default: 28. |
| 231 | 234 | ||
| 232 | .TP | 235 | .TP |
| 233 | .BI \-T\ template \fR,\ \fB\-\-digital\-clock\-template= template | 236 | .BI \-T\ template \fR,\ \fB\-\-digital\-clock\-template= template |
| @@ -239,6 +242,10 @@ If an image is specified (via \-i) it will display the image tiled all over the | |||
| 239 | (if it is a multi-monitor setup, the image is visible on all screens). | 242 | (if it is a multi-monitor setup, the image is visible on all screens). |
| 240 | 243 | ||
| 241 | .TP | 244 | .TP |
| 245 | .B \-U, \-\-unix-time | ||
| 246 | Display UNIX time (seconds since Epoch) | ||
| 247 | |||
| 248 | .TP | ||
| 242 | .B \-u, \-\-no-unlock-indicator | 249 | .B \-u, \-\-no-unlock-indicator |
| 243 | Disable the unlock indicator. i3lock will by default show an unlock indicator | 250 | Disable the unlock indicator. i3lock will by default show an unlock indicator |
| 244 | after pressing keys. This will give feedback for every keypress and it will | 251 | after pressing keys. This will give feedback for every keypress and it will |
| @@ -251,8 +258,8 @@ Display the version of your | |||
| 251 | .B i3lock | 258 | .B i3lock |
| 252 | 259 | ||
| 253 | .TP | 260 | .TP |
| 254 | .BI \-W\ halign \fR,\ \fB\-\-elapsed\-time\-halign= halign | 261 | .BI \-W\ halign \fR,\ \fB\-\-display\-text\-halign= halign |
| 255 | The horizontal alignment for elapsed time and display-text. | 262 | The horizontal alignment for display text, elapsed time and UNIX time. |
| 256 | Valid halign values: left, center, right. Default: right | 263 | Valid halign values: left, center, right. Default: right |
| 257 | 264 | ||
| 258 | .TP | 265 | .TP |
| @@ -273,8 +280,8 @@ Valid valign values: top, middle, bottom. Default: bottom | |||
| 273 | The vertical alignment for the digital clock. Default: top | 280 | The vertical alignment for the digital clock. Default: top |
| 274 | 281 | ||
| 275 | .TP | 282 | .TP |
| 276 | .BI \-Z\ valign \fR,\ \fB\-\-elapsed\-time\-valign= valign | 283 | .BI \-Z\ valign \fR,\ \fB\-\-display\-text\-valign= valign |
| 277 | The vertical alignment for elapsed time and display-text. Default: bottom | 284 | The vertical alignment for display text, elapsed time and UNIX time. Default: bottom |
| 278 | 285 | ||
| 279 | .SH DPMS | 286 | .SH DPMS |
| 280 | 287 | ||
| @@ -84,6 +84,7 @@ static void input_done(void); | |||
| 84 | bool digital_clock = false; | 84 | bool digital_clock = false; |
| 85 | bool led_clock = false; | 85 | bool led_clock = false; |
| 86 | bool elapsed_time = false; | 86 | bool elapsed_time = false; |
| 87 | bool unix_time = false; /* display seconds since epoch */ | ||
| 87 | int count_until = 0; /* count seconds until */ | 88 | int count_until = 0; /* count seconds until */ |
| 88 | int refresh_rate = 2; /* 2 frames per second */ | 89 | int refresh_rate = 2; /* 2 frames per second */ |
| 89 | i3lock_digital_clock_t i3lock_digital_clock = {28, | 90 | i3lock_digital_clock_t i3lock_digital_clock = {28, |
| @@ -103,7 +104,7 @@ i3lock_led_clock_t i3lock_led_clock = {"ffff00", | |||
| 103 | "000000", | 104 | "000000", |
| 104 | I3LOCK_ALIGN_CENTER, | 105 | I3LOCK_ALIGN_CENTER, |
| 105 | I3LOCK_ALIGN_BOTTOM}; | 106 | I3LOCK_ALIGN_BOTTOM}; |
| 106 | char *display_text = NULL; | 107 | char *display_text_template = NULL; |
| 107 | #endif | 108 | #endif |
| 108 | 109 | ||
| 109 | char color[7] = "a3a3a3"; | 110 | char color[7] = "a3a3a3"; |
| @@ -1081,17 +1082,17 @@ int main(int argc, char *argv[]) { | |||
| 1081 | {"dpms", no_argument, NULL, 'd'}, | 1082 | {"dpms", no_argument, NULL, 'd'}, |
| 1082 | {"color", required_argument, NULL, 'c'}, | 1083 | {"color", required_argument, NULL, 'c'}, |
| 1083 | #ifdef EXTRAS | 1084 | #ifdef EXTRAS |
| 1084 | {"count-until", no_argument, NULL, 'C'}, | 1085 | {"count-until", required_argument, NULL, 'C'}, |
| 1085 | {"digital-clock", no_argument, NULL, 'D'}, | 1086 | {"digital-clock", no_argument, NULL, 'D'}, |
| 1086 | {"digital-clock-color", required_argument, NULL, 'G'}, | 1087 | {"digital-clock-color", required_argument, NULL, 'G'}, |
| 1087 | {"digital-clock-template", required_argument, NULL, 'T'}, | 1088 | {"digital-clock-template", required_argument, NULL, 'T'}, |
| 1088 | {"digital-clock-halign", required_argument, NULL, 'x'}, | 1089 | {"digital-clock-halign", required_argument, NULL, 'x'}, |
| 1089 | {"digital-clock-valign", required_argument, NULL, 'y'}, | 1090 | {"digital-clock-valign", required_argument, NULL, 'y'}, |
| 1090 | {"display-text", no_argument, NULL, 'J'}, | 1091 | {"display-text", required_argument, NULL, 'J'}, |
| 1091 | {"elapsed-time", no_argument, NULL, 'E'}, | 1092 | {"elapsed-time", no_argument, NULL, 'E'}, |
| 1092 | {"elapsed-time-color", required_argument, NULL, 'R'}, | 1093 | {"display-text-color", required_argument, NULL, 'R'}, |
| 1093 | {"elapsed-time-halign", required_argument, NULL, 'W'}, | 1094 | {"display-text-halign", required_argument, NULL, 'W'}, |
| 1094 | {"elapsed-time-valign", required_argument, NULL, 'Z'}, | 1095 | {"display-text-valign", required_argument, NULL, 'Z'}, |
| 1095 | {"led-clock", no_argument, NULL, 'L'}, | 1096 | {"led-clock", no_argument, NULL, 'L'}, |
| 1096 | {"led-clock-halign", required_argument, NULL, 'X'}, | 1097 | {"led-clock-halign", required_argument, NULL, 'X'}, |
| 1097 | {"led-clock-valign", required_argument, NULL, 'Y'}, | 1098 | {"led-clock-valign", required_argument, NULL, 'Y'}, |
| @@ -1100,6 +1101,7 @@ int main(int argc, char *argv[]) { | |||
| 1100 | {"led-on-color", required_argument, NULL, 'O'}, | 1101 | {"led-on-color", required_argument, NULL, 'O'}, |
| 1101 | {"refresh-rate", required_argument, NULL, 'r'}, | 1102 | {"refresh-rate", required_argument, NULL, 'r'}, |
| 1102 | {"text-size", required_argument, NULL, 'S'}, | 1103 | {"text-size", required_argument, NULL, 'S'}, |
| 1104 | {"unix-time", no_argument, NULL, 'U'}, | ||
| 1103 | #endif | 1105 | #endif |
| 1104 | {"pointer", required_argument, NULL, 'p'}, | 1106 | {"pointer", required_argument, NULL, 'p'}, |
| 1105 | {"debug", no_argument, NULL, 0}, | 1107 | {"debug", no_argument, NULL, 0}, |
| @@ -1117,7 +1119,7 @@ int main(int argc, char *argv[]) { | |||
| 1117 | int code = EXIT_FAILURE; | 1119 | int code = EXIT_FAILURE; |
| 1118 | 1120 | ||
| 1119 | #ifdef EXTRAS | 1121 | #ifdef EXTRAS |
| 1120 | char *optstring = "hvnbDdELC:c:B:G:F:J:O:R:r:S:T:W:X:x:Y:y:Z:p:ui:teI:fk"; | 1122 | char *optstring = "hvnbDdELUC:c:B:G:F:J:O:R:r:S:T:W:X:x:Y:y:Z:p:ui:teI:fk"; |
| 1121 | #else | 1123 | #else |
| 1122 | char *optstring = "hvnbdc:p:ui:teI:fk"; | 1124 | char *optstring = "hvnbdc:p:ui:teI:fk"; |
| 1123 | #endif | 1125 | #endif |
| @@ -1163,6 +1165,9 @@ int main(int argc, char *argv[]) { | |||
| 1163 | digital_clock = true; | 1165 | digital_clock = true; |
| 1164 | break; | 1166 | break; |
| 1165 | case 'E': | 1167 | case 'E': |
| 1168 | if ((display_text_template != NULL) || (unix_time)) { | ||
| 1169 | errx(EXIT_FAILURE, "Display text, elapsed time and UNIX time are mutually exclusive options\n"); | ||
| 1170 | } | ||
| 1166 | elapsed_time = true; | 1171 | elapsed_time = true; |
| 1167 | i3lock_elapsed_time.start_time = time(NULL); | 1172 | i3lock_elapsed_time.start_time = time(NULL); |
| 1168 | break; | 1173 | break; |
| @@ -1205,13 +1210,16 @@ int main(int argc, char *argv[]) { | |||
| 1205 | DEBUG("led-off-color: %s\n", i3lock_led_clock.led_off_color); | 1210 | DEBUG("led-off-color: %s\n", i3lock_led_clock.led_off_color); |
| 1206 | break; | 1211 | break; |
| 1207 | } | 1212 | } |
| 1208 | case 'J': { | 1213 | case 'J': { /* display-text */ |
| 1209 | display_text = strdup(optarg); | 1214 | if ((elapsed_time) || (unix_time)) { |
| 1210 | if (display_text == NULL) { | 1215 | errx(EXIT_FAILURE, "Display text, elapsed time and UNIX time are mutually exclusive options\n"); |
| 1216 | } | ||
| 1217 | display_text_template = strdup(optarg); | ||
| 1218 | if (display_text_template == NULL) { | ||
| 1211 | errx(EXIT_FAILURE, | 1219 | errx(EXIT_FAILURE, |
| 1212 | "Unable to initialize display_text\n"); | 1220 | "Unable to initialize display_text\n"); |
| 1213 | } | 1221 | } |
| 1214 | DEBUG("display_text: %s\n", display_text); | 1222 | DEBUG("display_text: %s\n", display_text_template); |
| 1215 | break; | 1223 | break; |
| 1216 | } | 1224 | } |
| 1217 | case 'O': { /* led-on-color */ | 1225 | case 'O': { /* led-on-color */ |
| @@ -1226,16 +1234,17 @@ int main(int argc, char *argv[]) { | |||
| 1226 | DEBUG("led-on-color: %s\n", i3lock_led_clock.led_on_color); | 1234 | DEBUG("led-on-color: %s\n", i3lock_led_clock.led_on_color); |
| 1227 | break; | 1235 | break; |
| 1228 | } | 1236 | } |
| 1229 | case 'R': { /* elapsed-time-color */ | 1237 | case 'R': { /* display-text-color */ |
| 1230 | char *arg = optarg; | 1238 | char *arg = optarg; |
| 1231 | 1239 | ||
| 1232 | /* Skip # if present */ | 1240 | /* Skip # if present */ |
| 1233 | if (arg[0] == '#') | 1241 | if (arg[0] == '#') |
| 1234 | arg++; | 1242 | arg++; |
| 1235 | 1243 | ||
| 1244 | /* since display-text is a subset of elapsed time, we store it in a i3lock_elapsed_time */ | ||
| 1236 | if (strlen(arg) != 6 || sscanf(arg, "%06[0-9a-fA-F]", i3lock_elapsed_time.color) != 1) | 1245 | if (strlen(arg) != 6 || sscanf(arg, "%06[0-9a-fA-F]", i3lock_elapsed_time.color) != 1) |
| 1237 | errx(EXIT_FAILURE, "elapsed-time-color is invalid, it must be given in 3-byte hexadecimal format: rrggbb\n"); | 1246 | errx(EXIT_FAILURE, "display-text-color is invalid, it must be given in 3-byte hexadecimal format: rrggbb\n"); |
| 1238 | DEBUG("elapsed-time-color: %s\n", i3lock_elapsed_time.color); | 1247 | DEBUG("display-text-color: %s\n", i3lock_elapsed_time.color); |
| 1239 | break; | 1248 | break; |
| 1240 | } | 1249 | } |
| 1241 | case 'r': /* refresh-rate */ | 1250 | case 'r': /* refresh-rate */ |
| @@ -1254,17 +1263,23 @@ int main(int argc, char *argv[]) { | |||
| 1254 | DEBUG("digital-clock-template: %s\n", | 1263 | DEBUG("digital-clock-template: %s\n", |
| 1255 | i3lock_digital_clock.template); | 1264 | i3lock_digital_clock.template); |
| 1256 | break; | 1265 | break; |
| 1257 | case 'W': /* elapsed-time-halign */ | 1266 | case 'U': /* UNIX time (epoch time) */ |
| 1267 | if ((display_text_template != NULL) || (elapsed_time)) { | ||
| 1268 | errx(EXIT_FAILURE, "Display text, elapsed time and UNIX time are mutually exclusive options\n"); | ||
| 1269 | } | ||
| 1270 | unix_time = true; | ||
| 1271 | break; | ||
| 1272 | case 'W': /* display-text-halign */ | ||
| 1258 | /* the default is right */ | 1273 | /* the default is right */ |
| 1259 | if (strcasecmp(optarg, "left") == 0) { | 1274 | if (strcasecmp(optarg, "left") == 0) { |
| 1260 | i3lock_elapsed_time.horizontal_alignment = I3LOCK_ALIGN_LEFT; | 1275 | i3lock_elapsed_time.horizontal_alignment = I3LOCK_ALIGN_LEFT; |
| 1261 | DEBUG("elapsed-time-halign: left\n"); | 1276 | DEBUG("display-text-halign: left\n"); |
| 1262 | } else if (strcasecmp(optarg, "center") == 0) { | 1277 | } else if (strcasecmp(optarg, "center") == 0) { |
| 1263 | i3lock_elapsed_time.horizontal_alignment = I3LOCK_ALIGN_CENTER; | 1278 | i3lock_elapsed_time.horizontal_alignment = I3LOCK_ALIGN_CENTER; |
| 1264 | DEBUG("elapsed-time-halign: center\n"); | 1279 | DEBUG("display-text-halign: center\n"); |
| 1265 | } else { | 1280 | } else { |
| 1266 | /* value already set */ | 1281 | /* value already set */ |
| 1267 | DEBUG("elapsed-time-halign: right\n"); | 1282 | DEBUG("display-tex-halign: right\n"); |
| 1268 | } | 1283 | } |
| 1269 | break; | 1284 | break; |
| 1270 | case 'X': /* led-clock-halign */ | 1285 | case 'X': /* led-clock-halign */ |
| @@ -1319,17 +1334,17 @@ int main(int argc, char *argv[]) { | |||
| 1319 | DEBUG("digital-clock-valign: top\n"); | 1334 | DEBUG("digital-clock-valign: top\n"); |
| 1320 | } | 1335 | } |
| 1321 | break; | 1336 | break; |
| 1322 | case 'Z': /* elapsed-time-valign */ | 1337 | case 'Z': /* display-tex-valign */ |
| 1323 | /* the default is bottom */ | 1338 | /* the default is bottom */ |
| 1324 | if (strcasecmp(optarg, "middle") == 0) { | 1339 | if (strcasecmp(optarg, "middle") == 0) { |
| 1325 | i3lock_elapsed_time.vertical_alignment = I3LOCK_ALIGN_MIDDLE; | 1340 | i3lock_elapsed_time.vertical_alignment = I3LOCK_ALIGN_MIDDLE; |
| 1326 | DEBUG("elapsed-time-valign: middle\n"); | 1341 | DEBUG("display-tex-valign: middle\n"); |
| 1327 | } else if (strcasecmp(optarg, "top") == 0) { | 1342 | } else if (strcasecmp(optarg, "top") == 0) { |
| 1328 | i3lock_elapsed_time.vertical_alignment = I3LOCK_ALIGN_TOP; | 1343 | i3lock_elapsed_time.vertical_alignment = I3LOCK_ALIGN_TOP; |
| 1329 | DEBUG("elapsed-time-valign: top\n"); | 1344 | DEBUG("display-text-valign: top\n"); |
| 1330 | } else { | 1345 | } else { |
| 1331 | /* value already set */ | 1346 | /* value already set */ |
| 1332 | DEBUG("elapsed-time-valign: bottom\n"); | 1347 | DEBUG("display-text-valign: bottom\n"); |
| 1333 | } | 1348 | } |
| 1334 | break; | 1349 | break; |
| 1335 | #endif | 1350 | #endif |
| @@ -1378,8 +1393,8 @@ int main(int argc, char *argv[]) { | |||
| 1378 | "[-c color] [-D] [-d] [-E] [-e] [-F color] [-f] [-k]" | 1393 | "[-c color] [-D] [-d] [-E] [-e] [-F color] [-f] [-k]" |
| 1379 | "[-G color] [-h] [-I timeout] [-i image.png] [-J text] " | 1394 | "[-G color] [-h] [-I timeout] [-i image.png] [-J text] " |
| 1380 | "[-L] [-n] [-O color] [-p win|default] [-R color] " | 1395 | "[-L] [-n] [-O color] [-p win|default] [-R color] " |
| 1381 | "[-r refresh rate] [-S size] [-T template] [-t] [-u] [-v] " | 1396 | "[-r refresh rate] [-S size] [-T template] [-t] [-U] [-u] " |
| 1382 | "[-W horizontal-alignment] [-X horizontal-alignment] " | 1397 | "[-v] [-W horizontal-alignment] [-X horizontal-alignment] " |
| 1383 | "[-x horizontal-alignment] [-Y vertical-alignment] " | 1398 | "[-x horizontal-alignment] [-Y vertical-alignment] " |
| 1384 | "[-y vertical-alignment] [-Z vertical-alignment]"); | 1399 | "[-y vertical-alignment] [-Z vertical-alignment]"); |
| 1385 | #else | 1400 | #else |
diff --git a/include/extras.h b/include/extras.h index 4f791d8..3e3b51c 100644 --- a/include/extras.h +++ b/include/extras.h | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * This file is part of i3lock-extended | 2 | * This file is part of i3lock-extended |
| 3 | * Copyright (C) 2020-2023 Simeon Simeonov | 3 | * Copyright (C) 2020-2024 Simeon Simeonov |
| 4 | 4 | ||
| 5 | * i3lock-extended is free software: you can redistribute it and/or modify | 5 | * i3lock-extended is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
diff --git a/meson.build b/meson.build index 6960930..a69decc 100644 --- a/meson.build +++ b/meson.build | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | project( | 6 | project( |
| 7 | 'i3lock-extended', | 7 | 'i3lock-extended', |
| 8 | 'c', | 8 | 'c', |
| 9 | version: '2.2.15', | 9 | version: '3.2.15', |
| 10 | default_options: [ | 10 | default_options: [ |
| 11 | 'c_std=c11', | 11 | 'c_std=c11', |
| 12 | 'warning_level=1', # enable all warnings (-Wall) | 12 | 'warning_level=1', # enable all warnings (-Wall) |
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 | } |
