Browse Source

expose separator color for theming + bug fix

I did a double take, apparently he messed up a copy/paste.
master
Chris Guillott 9 years ago
parent
commit
7fb899bcd5
  1. 7
      README.md
  2. 12
      i3lock.c
  3. 67
      unlock_indicator.c

7
README.md

@ -23,10 +23,13 @@ Many little improvements have been made to i3lock over time:
- `--ringvercolor=rrggbbaa` -- Outer ring while the password is being verified - `--ringvercolor=rrggbbaa` -- Outer ring while the password is being verified
- `--ringwrongcolor=rrggbbaa` -- Outer ring when a wrong password was entered - `--ringwrongcolor=rrggbbaa` -- Outer ring when a wrong password was entered
- `--ringcolor=rrggbbaa` -- Outer ring while typing/idle - `--ringcolor=rrggbbaa` -- Outer ring while typing/idle
- `--linecolor=rrggbbaa` -- Line separating outer ring from inside of the circle and delimiting the highlight segments - `--linecolor=rrggbbaa` -- Line separating outer ring from inside of the circle
- `--separatorcolor=rrggbbaa` -- Lines delimiting the highlight segments
- `--textcolor=rrggbbaa` -- Text ("verifying", "wrong!") - `--textcolor=rrggbbaa` -- Text ("verifying", "wrong!")
- `--keyhlcolor=rrggbbaa` -- Keypress highlight segments - `--keyhlcolor=rrggbbaa` -- Keypress highlight segments
- `--bshlcolor=rrggbbaa` -- Backspace highlight segments - `--bshlcolor=rrggbbaa` -- Backspace highlight segments
- `--line-uses-ring`, `-r` -- the line between the inside and outer ring uses the ring color for its color
- `--line-uses-inside`, `-s` -- the line between the inside and outer ring uses the inside color for its color
- All the colors have an alpha channel now. Please keep in mind that this was not intended when the program was originally written, so making things transparent that weren't before can make it look strange. - All the colors have an alpha channel now. Please keep in mind that this was not intended when the program was originally written, so making things transparent that weren't before can make it look strange.
- You can specify whether i3lock should bell upon a wrong password. - You can specify whether i3lock should bell upon a wrong password.
@ -54,7 +57,7 @@ press enter.
Example usage for colors: Example usage for colors:
i3lock --insidevercolor=0000a0bf --insidewrongcolor=ff8000bf --insidecolor=ffffffbf --ringvercolor=0020ffff --ringwrongcolor=4040ffff --ringcolor=404090ff --textcolor=ffffffff --linecolor=aaaaaaff --keyhlcolor=30ccccff --bshlcolor=ff8000ff i3lock --insidevercolor=0000a0bf --insidewrongcolor=ff8000bf --insidecolor=ffffffbf --ringvercolor=0020ffff --ringwrongcolor=4040ffff --ringcolor=404090ff --textcolor=ffffffff --linecolor=aaaaaaff --keyhlcolor=30ccccff --bshlcolor=ff8000ff -r
Upstream Upstream

12
i3lock.c

@ -57,6 +57,7 @@ char linecolor[9] = "000000ff";
char textcolor[9] = "000000ff"; char textcolor[9] = "000000ff";
char keyhlcolor[9] = "33db00ff"; char keyhlcolor[9] = "33db00ff";
char bshlcolor[9] = "db3300ff"; char bshlcolor[9] = "db3300ff";
char separatorcolor[9] = "000000ff";
/* default is to use the supplied line color, 1 will be ring color, 2 will be to use the inside color for ver/wrong/etc */ /* default is to use the supplied line color, 1 will be ring color, 2 will be to use the inside color for ver/wrong/etc */
int internal_line_source = 0; int internal_line_source = 0;
@ -784,6 +785,7 @@ int main(int argc, char *argv[]) {
{"textcolor", required_argument, NULL, 0}, // --t-c {"textcolor", required_argument, NULL, 0}, // --t-c
{"keyhlcolor", required_argument, NULL, 0}, // --k-c {"keyhlcolor", required_argument, NULL, 0}, // --k-c
{"bshlcolor", required_argument, NULL, 0}, // --b-c {"bshlcolor", required_argument, NULL, 0}, // --b-c
{"separatorcolor", required_argument, NULL, 0},
{"line-uses-ring", no_argument, NULL, 'r'}, {"line-uses-ring", no_argument, NULL, 'r'},
{"line-uses-inside", no_argument, NULL, 's'}, {"line-uses-inside", no_argument, NULL, 's'},
/* s for in_s_ide; ideally I'd use -I but that's used for timeout, which should use -T, but compatibility argh */ /* s for in_s_ide; ideally I'd use -I but that's used for timeout, which should use -T, but compatibility argh */
@ -966,6 +968,16 @@ int main(int argc, char *argv[]) {
if (strlen(arg) != 8 || sscanf(arg, "%08[0-9a-fA-F]", bshlcolor) != 1) if (strlen(arg) != 8 || sscanf(arg, "%08[0-9a-fA-F]", bshlcolor) != 1)
errx(1, "bshlcolor is invalid, color must be given in 8-byte format: rrggbb\n"); errx(1, "bshlcolor is invalid, color must be given in 8-byte format: rrggbb\n");
} }
else if (strcmp(longopts[optind].name, "separatorcolor") == 0) {
char *arg = optarg;
/* Skip # if present */
if (arg[0] == '#')
arg++;
if (strlen(arg) != 8 || sscanf(arg, "%08[0-9a-fA-F]", separatorcolor) != 1)
errx(1, "separator is invalid, color must be given in 8-byte format: rrggbb\n");
}
break; break;
case 'f': case 'f':
show_failed_attempts = true; show_failed_attempts = true;

67
unlock_indicator.c

@ -66,6 +66,7 @@ extern char linecolor[9];
extern char textcolor[9]; extern char textcolor[9];
extern char keyhlcolor[9]; extern char keyhlcolor[9];
extern char bshlcolor[9]; extern char bshlcolor[9];
extern char separatorcolor[9];
extern int internal_line_source; extern int internal_line_source;
/* Whether the failed attempts should be displayed. */ /* Whether the failed attempts should be displayed. */
@ -217,22 +218,30 @@ xcb_pixmap_t draw_image(uint32_t *resolution) {
(strtol(strgroupst[1], NULL, 16)), (strtol(strgroupst[1], NULL, 16)),
(strtol(strgroupst[2], NULL, 16)), (strtol(strgroupst[2], NULL, 16)),
(strtol(strgroupst[3], NULL, 16))}; (strtol(strgroupst[3], NULL, 16))};
char strgroupsk[4][3] = {{keyhlcolor[0], textcolor[1], '\0'}, char strgroupsk[4][3] = {{keyhlcolor[0], keyhlcolor[1], '\0'},
{keyhlcolor[2], textcolor[3], '\0'}, {keyhlcolor[2], keyhlcolor[3], '\0'},
{keyhlcolor[4], textcolor[5], '\0'}, {keyhlcolor[4], keyhlcolor[5], '\0'},
{keyhlcolor[6], textcolor[7], '\0'}}; {keyhlcolor[6], keyhlcolor[7], '\0'}};
uint32_t keyhl16[4] = {(strtol(strgroupsk[0], NULL, 16)), uint32_t keyhl16[4] = {(strtol(strgroupsk[0], NULL, 16)),
(strtol(strgroupsk[1], NULL, 16)), (strtol(strgroupsk[1], NULL, 16)),
(strtol(strgroupsk[2], NULL, 16)), (strtol(strgroupsk[2], NULL, 16)),
(strtol(strgroupsk[3], NULL, 16))}; (strtol(strgroupsk[3], NULL, 16))};
char strgroupsb[4][3] = {{bshlcolor[0], textcolor[1], '\0'}, char strgroupsb[4][3] = {{bshlcolor[0], bshlcolor[1], '\0'},
{bshlcolor[2], textcolor[3], '\0'}, {bshlcolor[2], bshlcolor[3], '\0'},
{bshlcolor[4], textcolor[5], '\0'}, {bshlcolor[4], bshlcolor[5], '\0'},
{bshlcolor[6], textcolor[7], '\0'}}; {bshlcolor[6], bshlcolor[7], '\0'}};
uint32_t bshl16[4] = {(strtol(strgroupsb[0], NULL, 16)), uint32_t bshl16[4] = {(strtol(strgroupsb[0], NULL, 16)),
(strtol(strgroupsb[1], NULL, 16)), (strtol(strgroupsb[1], NULL, 16)),
(strtol(strgroupsb[2], NULL, 16)), (strtol(strgroupsb[2], NULL, 16)),
(strtol(strgroupsb[3], NULL, 16))}; (strtol(strgroupsb[3], NULL, 16))};
char strgroupss[4][3] = {{separatorcolor[0], separatorcolor[1], '\0'},
{separatorcolor[2], separatorcolor[3], '\0'},
{separatorcolor[4], separatorcolor[5], '\0'},
{separatorcolor[6], separatorcolor[7], '\0'}};
uint32_t sep16[4] = {(strtol(strgroupss[0], NULL, 16)),
(strtol(strgroupss[1], NULL, 16)),
(strtol(strgroupss[2], NULL, 16)),
(strtol(strgroupss[3], NULL, 16))};
if (unlock_indicator && if (unlock_indicator &&
(unlock_state >= STATE_KEY_PRESSED || pam_state > STATE_PAM_IDLE)) { (unlock_state >= STATE_KEY_PRESSED || pam_state > STATE_PAM_IDLE)) {
@ -251,30 +260,12 @@ xcb_pixmap_t draw_image(uint32_t *resolution) {
switch (pam_state) { switch (pam_state) {
case STATE_PAM_VERIFY: case STATE_PAM_VERIFY:
cairo_set_source_rgba(ctx, (double)insidever16[0]/255, (double)insidever16[1]/255, (double)insidever16[2]/255, (double)insidever16[3]/255); cairo_set_source_rgba(ctx, (double)insidever16[0]/255, (double)insidever16[1]/255, (double)insidever16[2]/255, (double)insidever16[3]/255);
if (internal_line_source == 2) {
line16[0] = insidever16[0];
line16[1] = insidever16[1];
line16[2] = insidever16[2];
line16[3] = insidever16[3];
}
break; break;
case STATE_PAM_WRONG: case STATE_PAM_WRONG:
cairo_set_source_rgba(ctx, (double)insidewrong16[0]/255, (double)insidewrong16[1]/255, (double)insidewrong16[2]/255, (double)insidewrong16[3]/255); cairo_set_source_rgba(ctx, (double)insidewrong16[0]/255, (double)insidewrong16[1]/255, (double)insidewrong16[2]/255, (double)insidewrong16[3]/255);
if (internal_line_source == 2) {
line16[0] = insidewrong16[0];
line16[1] = insidewrong16[1];
line16[2] = insidewrong16[2];
line16[3] = insidewrong16[3];
}
break; break;
default: default:
cairo_set_source_rgba(ctx, (double)inside16[0]/255, (double)inside16[1]/255, (double)inside16[2]/255, (double)inside16[3]/255); cairo_set_source_rgba(ctx, (double)inside16[0]/255, (double)inside16[1]/255, (double)inside16[2]/255, (double)inside16[3]/255);
if (internal_line_source == 2) {
line16[0] = inside16[0];
line16[1] = inside16[1];
line16[2] = inside16[2];
line16[3] = inside16[3];
}
break; break;
} }
cairo_fill_preserve(ctx); cairo_fill_preserve(ctx);
@ -310,16 +301,18 @@ xcb_pixmap_t draw_image(uint32_t *resolution) {
} }
cairo_stroke(ctx); cairo_stroke(ctx);
/* Draw an inner seperator line. */ /* Draw an inner separator line. */
cairo_set_source_rgba(ctx, (double)line16[0]/255, (double)line16[1]/255, (double)line16[2]/255, (double)line16[3]/255); if (internal_line_source != 2) { //pretty sure this only needs drawn if it's being drawn over the inside?
cairo_set_line_width(ctx, 2.0); cairo_set_source_rgba(ctx, (double)line16[0]/255, (double)line16[1]/255, (double)line16[2]/255, (double)line16[3]/255);
cairo_arc(ctx, cairo_set_line_width(ctx, 2.0);
BUTTON_CENTER /* x */, cairo_arc(ctx,
BUTTON_CENTER /* y */, BUTTON_CENTER /* x */,
BUTTON_RADIUS - 5 /* radius */, BUTTON_CENTER /* y */,
0, BUTTON_RADIUS - 5 /* radius */,
2 * M_PI); 0,
cairo_stroke(ctx); 2 * M_PI);
cairo_stroke(ctx);
}
cairo_set_line_width(ctx, 10.0); cairo_set_line_width(ctx, 10.0);
@ -403,7 +396,7 @@ xcb_pixmap_t draw_image(uint32_t *resolution) {
/* Draw two little separators for the highlighted part of the /* Draw two little separators for the highlighted part of the
* unlock indicator. */ * unlock indicator. */
cairo_set_source_rgba(ctx, (double)line16[0]/255, (double)line16[1]/255, (double)line16[2]/255, (double)line16[3]/255); cairo_set_source_rgba(ctx, (double)sep16[0]/255, (double)sep16[1]/255, (double)sep16[2]/255, (double)sep16[3]/255);
cairo_arc(ctx, cairo_arc(ctx,
BUTTON_CENTER /* x */, BUTTON_CENTER /* x */,
BUTTON_CENTER /* y */, BUTTON_CENTER /* y */,

Loading…
Cancel
Save