Browse Source

add in more specific status text positioning

master
Cassandra 7 years ago
parent
commit
dd44aab1bd
No known key found for this signature in database GPG Key ID: 55DB77C2A03E1EF5
  1. 50
      i3lock.c
  2. 50
      unlock_indicator.c

50
i3lock.c

@ -143,6 +143,10 @@ char status_x_expr[32] = "ix\0";
char status_y_expr[32] = "iy\0"; char status_y_expr[32] = "iy\0";
char modif_x_expr[32] = "ix\0"; char modif_x_expr[32] = "ix\0";
char modif_y_expr[32] = "iy+28\0"; char modif_y_expr[32] = "iy+28\0";
char verif_x_expr[32] = "ix\0";
char verif_y_expr[32] = "iy\0";
char wrong_x_expr[32] = "ix\0";
char wrong_y_expr[32] = "iy\0";
double time_size = 32.0; double time_size = 32.0;
double date_size = 14.0; double date_size = 14.0;
@ -1160,10 +1164,12 @@ int main(int argc, char *argv[]) {
{"timepos", required_argument, NULL, 540}, {"timepos", required_argument, NULL, 540},
{"datepos", required_argument, NULL, 541}, {"datepos", required_argument, NULL, 541},
{"layoutpos", required_argument, NULL, 542}, {"verifpos", required_argument, NULL, 542},
{"statuspos", required_argument, NULL, 543}, {"wrongpos", required_argument, NULL, 543},
{"modifpos", required_argument, NULL, 544}, {"layoutpos", required_argument, NULL, 544},
{"indpos", required_argument, NULL, 545}, {"statuspos", required_argument, NULL, 545},
{"modifpos", required_argument, NULL, 546},
{"indpos", required_argument, NULL, 547},
// bar indicator stuff // bar indicator stuff
@ -1493,9 +1499,7 @@ int main(int argc, char *argv[]) {
break; break;
// Positions // Positions
case 540: case 540:
//read in to time_x_expr and time_y_expr
if (strlen(optarg) > 31) { if (strlen(optarg) > 31) {
// this is overly restrictive since both the x and y string buffers have size 32, but it's easier to check.
errx(1, "time position string can be at most 31 characters\n"); errx(1, "time position string can be at most 31 characters\n");
} }
arg = optarg; arg = optarg;
@ -1504,9 +1508,7 @@ int main(int argc, char *argv[]) {
} }
break; break;
case 541: case 541:
//read in to date_x_expr and date_y_expr
if (strlen(optarg) > 31) { if (strlen(optarg) > 31) {
// this is overly restrictive since both the x and y string buffers have size 32, but it's easier to check.
errx(1, "date position string can be at most 31 characters\n"); errx(1, "date position string can be at most 31 characters\n");
} }
arg = optarg; arg = optarg;
@ -1515,9 +1517,25 @@ int main(int argc, char *argv[]) {
} }
break; break;
case 542: case 542:
//read in to time_x_expr and time_y_expr
if (strlen(optarg) > 31) { if (strlen(optarg) > 31) {
// this is overly restrictive since both the x and y string buffers have size 32, but it's easier to check. errx(1, "verif position string can be at most 31 characters\n");
}
arg = optarg;
if (sscanf(arg, "%30[^:]:%30[^:]", verif_x_expr, verif_y_expr) != 2) {
errx(1, "verifpos must be of the form x:y\n");
}
break;
case 543:
if (strlen(optarg) > 31) {
errx(1, "\"wrong\" text position string can be at most 31 characters\n");
}
arg = optarg;
if (sscanf(arg, "%30[^:]:%30[^:]", wrong_x_expr, wrong_y_expr) != 2) {
errx(1, "verifpos must be of the form x:y\n");
}
break;
case 544:
if (strlen(optarg) > 31) {
errx(1, "layout position string can be at most 31 characters\n"); errx(1, "layout position string can be at most 31 characters\n");
} }
arg = optarg; arg = optarg;
@ -1525,10 +1543,8 @@ int main(int argc, char *argv[]) {
errx(1, "layoutpos must be of the form x:y\n"); errx(1, "layoutpos must be of the form x:y\n");
} }
break; break;
case 543: case 545:
//read in to time_x_expr and time_y_expr
if (strlen(optarg) > 31) { if (strlen(optarg) > 31) {
// this is overly restrictive since both the x and y string buffers have size 32, but it's easier to check.
errx(1, "status position string can be at most 31 characters\n"); errx(1, "status position string can be at most 31 characters\n");
} }
arg = optarg; arg = optarg;
@ -1536,10 +1552,8 @@ int main(int argc, char *argv[]) {
errx(1, "statuspos must be of the form x:y\n"); errx(1, "statuspos must be of the form x:y\n");
} }
break; break;
case 544: case 546:
//read in to time_x_expr and time_y_expr
if (strlen(optarg) > 31) { if (strlen(optarg) > 31) {
// this is overly restrictive since both the x and y string buffers have size 32, but it's easier to check.
errx(1, "modif position string can be at most 31 characters\n"); errx(1, "modif position string can be at most 31 characters\n");
} }
arg = optarg; arg = optarg;
@ -1547,10 +1561,8 @@ int main(int argc, char *argv[]) {
errx(1, "modifpos must be of the form x:y\n"); errx(1, "modifpos must be of the form x:y\n");
} }
break; break;
case 545: case 547:
//read in to ind_x_expr and ind_y_expr
if (strlen(optarg) > 31) { if (strlen(optarg) > 31) {
// this is overly restrictive since both the x and y string buffers have size 32, but it's easier to check.
errx(1, "indicator position string can be at most 31 characters\n"); errx(1, "indicator position string can be at most 31 characters\n");
} }
arg = optarg; arg = optarg;

50
unlock_indicator.c

@ -107,6 +107,10 @@ extern char layout_x_expr[32];
extern char layout_y_expr[32]; extern char layout_y_expr[32];
extern char status_x_expr[32]; extern char status_x_expr[32];
extern char status_y_expr[32]; extern char status_y_expr[32];
extern char verif_x_expr[32];
extern char verif_y_expr[32];
extern char wrong_x_expr[32];
extern char wrong_y_expr[32];
extern char modif_x_expr[32]; extern char modif_x_expr[32];
extern char modif_y_expr[32]; extern char modif_y_expr[32];
@ -852,6 +856,10 @@ xcb_pixmap_t draw_image(uint32_t *resolution) {
te_expr *te_layout_y_expr = compile_expression("--layoutpos", layout_y_expr, vars, vars_size); te_expr *te_layout_y_expr = compile_expression("--layoutpos", layout_y_expr, vars, vars_size);
te_expr *te_status_x_expr = compile_expression("--statuspos", status_x_expr, vars, vars_size); te_expr *te_status_x_expr = compile_expression("--statuspos", status_x_expr, vars, vars_size);
te_expr *te_status_y_expr = compile_expression("--statuspos", status_y_expr, vars, vars_size); te_expr *te_status_y_expr = compile_expression("--statuspos", status_y_expr, vars, vars_size);
te_expr *te_verif_x_expr = compile_expression("--verifpos", verif_x_expr, vars, vars_size);
te_expr *te_verif_y_expr = compile_expression("--verifpos", verif_y_expr, vars, vars_size);
te_expr *te_wrong_x_expr = compile_expression("--wrongpos", wrong_x_expr, vars, vars_size);
te_expr *te_wrong_y_expr = compile_expression("--wrongpos", wrong_y_expr, vars, vars_size);
te_expr *te_modif_x_expr = compile_expression("--modifpos", modif_x_expr, vars, vars_size); te_expr *te_modif_x_expr = compile_expression("--modifpos", modif_x_expr, vars, vars_size);
te_expr *te_modif_y_expr = compile_expression("--modifpos", modif_y_expr, vars, vars_size); te_expr *te_modif_y_expr = compile_expression("--modifpos", modif_y_expr, vars, vars_size);
te_expr *te_bar_expr = compile_expression("--bar-position", bar_expr, vars, vars_size); te_expr *te_bar_expr = compile_expression("--bar-position", bar_expr, vars, vars_size);
@ -891,8 +899,24 @@ xcb_pixmap_t draw_image(uint32_t *resolution) {
draw_data.date_text.y = te_eval(te_date_y_expr); draw_data.date_text.y = te_eval(te_date_y_expr);
draw_data.keylayout_text.x = te_eval(te_layout_x_expr); draw_data.keylayout_text.x = te_eval(te_layout_x_expr);
draw_data.keylayout_text.y = te_eval(te_layout_y_expr); draw_data.keylayout_text.y = te_eval(te_layout_y_expr);
draw_data.status_text.x = te_eval(te_status_x_expr);
draw_data.status_text.y = te_eval(te_status_y_expr); switch (auth_state) {
case STATE_AUTH_VERIFY:
case STATE_AUTH_LOCK:
draw_data.status_text.x = te_eval(te_verif_x_expr);
draw_data.status_text.y = te_eval(te_verif_y_expr);
break;
case STATE_AUTH_WRONG:
case STATE_I3LOCK_LOCK_FAILED:
draw_data.status_text.x = te_eval(te_wrong_x_expr);
draw_data.status_text.y = te_eval(te_wrong_y_expr);
break;
default:
draw_data.status_text.x = te_eval(te_status_x_expr);
draw_data.status_text.y = te_eval(te_status_y_expr);
break;
}
draw_data.mod_text.x = te_eval(te_modif_x_expr); draw_data.mod_text.x = te_eval(te_modif_x_expr);
draw_data.mod_text.y = te_eval(te_modif_y_expr); draw_data.mod_text.y = te_eval(te_modif_y_expr);
@ -923,8 +947,22 @@ xcb_pixmap_t draw_image(uint32_t *resolution) {
draw_data.date_text.y = te_eval(te_date_y_expr); draw_data.date_text.y = te_eval(te_date_y_expr);
draw_data.keylayout_text.x = te_eval(te_layout_x_expr); draw_data.keylayout_text.x = te_eval(te_layout_x_expr);
draw_data.keylayout_text.y = te_eval(te_layout_y_expr); draw_data.keylayout_text.y = te_eval(te_layout_y_expr);
draw_data.status_text.x = te_eval(te_status_x_expr); switch (auth_state) {
draw_data.status_text.y = te_eval(te_status_y_expr); case STATE_AUTH_VERIFY:
case STATE_AUTH_LOCK:
draw_data.status_text.x = te_eval(te_verif_x_expr);
draw_data.status_text.y = te_eval(te_verif_y_expr);
break;
case STATE_AUTH_WRONG:
case STATE_I3LOCK_LOCK_FAILED:
draw_data.status_text.x = te_eval(te_wrong_x_expr);
draw_data.status_text.y = te_eval(te_wrong_y_expr);
break;
default:
draw_data.status_text.x = te_eval(te_status_x_expr);
draw_data.status_text.y = te_eval(te_status_y_expr);
break;
}
draw_data.mod_text.x = te_eval(te_modif_x_expr); draw_data.mod_text.x = te_eval(te_modif_x_expr);
draw_data.mod_text.y = te_eval(te_modif_y_expr); draw_data.mod_text.y = te_eval(te_modif_y_expr);
@ -949,6 +987,10 @@ xcb_pixmap_t draw_image(uint32_t *resolution) {
te_free(te_layout_y_expr); te_free(te_layout_y_expr);
te_free(te_status_x_expr); te_free(te_status_x_expr);
te_free(te_status_y_expr); te_free(te_status_y_expr);
te_free(te_verif_x_expr);
te_free(te_verif_y_expr);
te_free(te_wrong_x_expr);
te_free(te_wrong_y_expr);
te_free(te_modif_x_expr); te_free(te_modif_x_expr);
te_free(te_modif_y_expr); te_free(te_modif_y_expr);
te_free(te_bar_expr); te_free(te_bar_expr);

Loading…
Cancel
Save