add some more options
This commit is contained in:
parent
d9f2e04bab
commit
6ec7c668cf
|
@ -49,6 +49,11 @@ Many little improvements have been made to i3lock over time:
|
|||
- `--datecolor=rrggbbaa` -- color of the date string
|
||||
- `--datefont="sans-serif"` -- font used for the date display
|
||||
- `--datesize=14` -- font size for the date display
|
||||
- `--veriftext="verifying…" -- text to be shown while verifying
|
||||
- `--wrongtext="wrong!" -- text to be shown upon an incorrect password being entered
|
||||
- `--textsize=28` -- font size for the status text
|
||||
- `--modsize=14` -- font size for the modifier keys listing
|
||||
- `--radius=90` -- the radius of the circle indicator
|
||||
|
||||
- You can specify whether i3lock should bell upon a wrong password.
|
||||
|
||||
|
|
28
i3lock.1
28
i3lock.1
|
@ -194,8 +194,8 @@ Sets the format used for generating the time string. See strftime(3) for a full
|
|||
Sets the font used to render the time string.
|
||||
|
||||
.TP
|
||||
.B \-\-timesize=32
|
||||
Sets the font size for rendering the time string.
|
||||
.B \-\-timesize=number
|
||||
Sets the font size for rendering the time string. Defaults to 32.
|
||||
|
||||
.TP
|
||||
.B \-\-timepos="x position:y position"
|
||||
|
@ -234,8 +234,8 @@ Sets the format used for generating the date string. See strftime(3) for a full
|
|||
Sets the font used to render the date string.
|
||||
|
||||
.TP
|
||||
.B \-\-datesize=14
|
||||
Sets the font size for rendering the date string.
|
||||
.B \-\-datesize=number
|
||||
Sets the font size for rendering the date string. Defaults to 14.
|
||||
|
||||
.TP
|
||||
.B \-\-datepos="x position:y position"
|
||||
|
@ -254,6 +254,26 @@ ty - the computed y value of the timestring, for the current display.
|
|||
.B \-\-refresh\-rate=seconds
|
||||
The refresh rate of the indicator, given in seconds. This should automatically align itself, but is somewhat buggy currently.
|
||||
|
||||
.TP
|
||||
.B \-\-veriftext="text"
|
||||
Sets the string to be shown while verifying the password/input/key/etc. Defaults to "verifying…".
|
||||
|
||||
.TP
|
||||
.B \-\-wrongtext="text"
|
||||
Sets the string to be shown upon entering an incorrect password. Defaults to "wrong!".
|
||||
|
||||
.TP
|
||||
.B \-\-textsize=number
|
||||
The fontsize of the status text. Defaults to 28.
|
||||
|
||||
.TP
|
||||
.B \-\-modsize=number
|
||||
The fontsize of the text listing all the active modifiers (caps lock, num lock, etc). Defaults to 14.
|
||||
|
||||
.TP
|
||||
.B \-\-radius
|
||||
The radius of the circle. Defaults to 90.
|
||||
|
||||
.SH DPMS
|
||||
|
||||
The \-d (\-\-dpms) option was removed from i3lock in version 2.8. There were
|
||||
|
|
62
i3lock.c
62
i3lock.c
|
@ -96,8 +96,14 @@ char time_y_expr[32] = "iy - (ch / 2)\0";
|
|||
char date_x_expr[32] = "tx\0";
|
||||
char date_y_expr[32] = "ty+30\0";
|
||||
|
||||
double time_size = 32;
|
||||
double date_size = 14;
|
||||
double time_size = 32.0;
|
||||
double date_size = 14.0;
|
||||
double text_size = 28.0;
|
||||
double modifier_size = 14.0;
|
||||
double circle_radius = 90.0;
|
||||
|
||||
char* verif_text = "verifying…";
|
||||
char* wrong_text = "wrong!";
|
||||
|
||||
/* opts for blurring */
|
||||
bool blur = false;
|
||||
|
@ -894,7 +900,9 @@ int main(int argc, char *argv[]) {
|
|||
{"no-unlock-indicator", no_argument, NULL, 'u'},
|
||||
{"image", required_argument, NULL, 'i'},
|
||||
{"tiling", no_argument, NULL, 't'},
|
||||
|
||||
{"ignore-empty-password", no_argument, NULL, 'e'},
|
||||
{"inactivity-timeout", required_argument, NULL, 'I'},
|
||||
{"show-failed-attempts", no_argument, NULL, 'f'},
|
||||
/* options for unlock indicator colors */
|
||||
// defining a lot of different chars here for the options -- TODO find a nicer way for this, maybe not offering single character options at all
|
||||
{"insidevercolor", required_argument, NULL, 0}, // --i-v
|
||||
|
@ -915,7 +923,7 @@ int main(int argc, char *argv[]) {
|
|||
/* s for in_s_ide; ideally I'd use -I but that's used for timeout, which should use -T, but compatibility argh
|
||||
* note: `I` has been deprecated for a while, so I might just remove that and reshuffle that? */
|
||||
{"screen", required_argument, NULL, 'S'},
|
||||
|
||||
{"blur", required_argument, NULL, 'B'},
|
||||
{"clock", no_argument, NULL, 'k'},
|
||||
{"indicator", no_argument, NULL, 0},
|
||||
{"refresh-rate", required_argument, NULL, 0},
|
||||
|
@ -930,11 +938,12 @@ int main(int argc, char *argv[]) {
|
|||
{"timepos", required_argument, NULL, 0},
|
||||
{"datepos", required_argument, NULL, 0},
|
||||
|
||||
{"blur", required_argument, NULL, 'B'},
|
||||
{"veriftext", required_argument, NULL, 0},
|
||||
{"wrongtext", required_argument, NULL, 0},
|
||||
{"textsize", required_argument, NULL, 0},
|
||||
{"modsize", required_argument, NULL, 0},
|
||||
{"radius", required_argument, NULL, 0},
|
||||
|
||||
{"ignore-empty-password", no_argument, NULL, 'e'},
|
||||
{"inactivity-timeout", required_argument, NULL, 'I'},
|
||||
{"show-failed-attempts", no_argument, NULL, 'f'},
|
||||
{NULL, no_argument, NULL, 0}};
|
||||
|
||||
if ((pw = getpwuid(getuid())) == NULL)
|
||||
|
@ -1230,12 +1239,47 @@ int main(int argc, char *argv[]) {
|
|||
else if (strcmp(longopts[optind].name, "no-composite") == 0) {
|
||||
composite = false;
|
||||
}
|
||||
else if (strcmp(longopts[optind].name, "veriftext") == 0) {
|
||||
verif_text = optarg;
|
||||
}
|
||||
else if (strcmp(longopts[optind].name, "wrongtext") == 0) {
|
||||
wrong_text = optarg;
|
||||
}
|
||||
else if (strcmp(longopts[optind].name, "textsize") == 0) {
|
||||
char *arg = optarg;
|
||||
|
||||
if (sscanf(arg, "%lf", &text_size) != 1)
|
||||
errx(1, "textsize must be a number\n");
|
||||
if (time_size < 1) {
|
||||
fprintf(stderr, "textsize must be a positive integer; ignoring...\n");
|
||||
text_size = 28.0;
|
||||
}
|
||||
}
|
||||
else if (strcmp(longopts[optind].name, "modsize") == 0) {
|
||||
char *arg = optarg;
|
||||
|
||||
if (sscanf(arg, "%lf", &modifier_size) != 1)
|
||||
errx(1, "modsize must be a number\n");
|
||||
if (modifier_size < 1) {
|
||||
fprintf(stderr, "modsize must be a positive integer; ignoring...\n");
|
||||
modifier_size = 14.0;
|
||||
}
|
||||
}
|
||||
else if (strcmp(longopts[optind].name, "radius") == 0) {
|
||||
char *arg = optarg;
|
||||
|
||||
if (sscanf(arg, "%lf", &circle_radius) != 1)
|
||||
errx(1, "radius must be a number\n");
|
||||
if (circle_radius < 1) {
|
||||
fprintf(stderr, "radius must be a positive integer; ignoring...\n");
|
||||
text_size = 90.0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'f':
|
||||
show_failed_attempts = true;
|
||||
break;
|
||||
default:
|
||||
// TODO: clean this up, use newlines
|
||||
errx(EXIT_FAILURE, "Syntax: i3lock [-v] [-n] [-b] [-d] [-c color] [-u] [-p win|default]"
|
||||
" [-i image.png] [-t] [-e] [-f]\n"
|
||||
"Please see the manpage for a full list of arguments.");
|
||||
|
|
|
@ -25,7 +25,9 @@
|
|||
/* clock stuff */
|
||||
#include <time.h>
|
||||
|
||||
#define BUTTON_RADIUS 90
|
||||
extern double circle_radius;
|
||||
|
||||
#define BUTTON_RADIUS (circle_radius)
|
||||
#define BUTTON_SPACE (BUTTON_RADIUS + 5)
|
||||
#define BUTTON_CENTER (BUTTON_RADIUS + 5)
|
||||
#define BUTTON_DIAMETER (2 * BUTTON_SPACE)
|
||||
|
@ -94,6 +96,12 @@ extern char date_y_expr[32];
|
|||
|
||||
extern double time_size;
|
||||
extern double date_size;
|
||||
extern double text_size;
|
||||
extern double modifier_size;
|
||||
|
||||
extern char* verif_text;
|
||||
extern char* wrong_text;
|
||||
|
||||
/* Whether the failed attempts should be displayed. */
|
||||
extern bool show_failed_attempts;
|
||||
/* Number of failed unlock attempts. */
|
||||
|
@ -394,16 +402,16 @@ xcb_pixmap_t draw_image(uint32_t *resolution) {
|
|||
|
||||
cairo_set_source_rgba(ctx, (double)text16[0]/255, (double)text16[1]/255, (double)text16[2]/255, (double)text16[3]/255);
|
||||
cairo_select_font_face(ctx, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
||||
cairo_set_font_size(ctx, 28.0);
|
||||
cairo_set_font_size(ctx, text_size);
|
||||
switch (auth_state) {
|
||||
case STATE_AUTH_VERIFY:
|
||||
text = "verifying…";
|
||||
text = verif_text;
|
||||
break;
|
||||
case STATE_AUTH_LOCK:
|
||||
text = "locking…";
|
||||
break;
|
||||
case STATE_AUTH_WRONG:
|
||||
text = "wrong!";
|
||||
text = wrong_text;
|
||||
break;
|
||||
case STATE_I3LOCK_LOCK_FAILED:
|
||||
text = "lock failed!";
|
||||
|
@ -439,7 +447,7 @@ xcb_pixmap_t draw_image(uint32_t *resolution) {
|
|||
cairo_text_extents_t extents;
|
||||
double x, y;
|
||||
|
||||
cairo_set_font_size(ctx, 14.0);
|
||||
cairo_set_font_size(ctx, modifier_size);
|
||||
|
||||
cairo_text_extents(ctx, modifier_string, &extents);
|
||||
x = BUTTON_CENTER - ((extents.width / 2) + extents.x_bearing);
|
||||
|
|
Loading…
Reference in New Issue