Browse Source

add option for single-display unlock indicator

master
Chris Guillott 9 years ago
parent
commit
ed326ee463
  1. 1
      README.md
  2. 8
      i3lock.c
  3. 1
      todo.md
  4. 23
      unlock_indicator.c

1
README.md

@ -30,6 +30,7 @@ Many little improvements have been made to i3lock over time:
- `--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-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 - `--line-uses-inside`, `-s` -- the line between the inside and outer ring uses the inside color for its color
- `-S, --screen` -- specifies which display to draw the unlock indicator on
- 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.

8
i3lock.c

@ -58,6 +58,8 @@ char textcolor[9] = "000000ff";
char keyhlcolor[9] = "33db00ff"; char keyhlcolor[9] = "33db00ff";
char bshlcolor[9] = "db3300ff"; char bshlcolor[9] = "db3300ff";
char separatorcolor[9] = "000000ff"; char separatorcolor[9] = "000000ff";
int screen_number = -1;
/* 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;
@ -789,6 +791,7 @@ int main(int argc, char *argv[]) {
{"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 */
{"screen", required_argument, NULL, 'S'},
{"ignore-empty-password", no_argument, NULL, 'e'}, {"ignore-empty-password", no_argument, NULL, 'e'},
{"inactivity-timeout", required_argument, NULL, 'I'}, {"inactivity-timeout", required_argument, NULL, 'I'},
{"show-failed-attempts", no_argument, NULL, 'f'}, {"show-failed-attempts", no_argument, NULL, 'f'},
@ -799,7 +802,7 @@ int main(int argc, char *argv[]) {
if ((username = pw->pw_name) == NULL) if ((username = pw->pw_name) == NULL)
errx(EXIT_FAILURE, "pw->pw_name is NULL.\n"); errx(EXIT_FAILURE, "pw->pw_name is NULL.\n");
char *optstring = "hvnbdc:p:ui:teI:frs"; char *optstring = "hvnbdc:p:ui:teI:frsS:";
while ((o = getopt_long(argc, argv, optstring, longopts, &optind)) != -1) { while ((o = getopt_long(argc, argv, optstring, longopts, &optind)) != -1) {
switch (o) { switch (o) {
case 'v': case 'v':
@ -865,6 +868,9 @@ int main(int argc, char *argv[]) {
} }
internal_line_source = 2; internal_line_source = 2;
break; break;
case 'S':
screen_number = atoi(optarg);
break;
case 0: case 0:
if (strcmp(longopts[optind].name, "debug") == 0) if (strcmp(longopts[optind].name, "debug") == 0)
debug_mode = true; debug_mode = true;

1
todo.md

@ -4,3 +4,4 @@ st for i3lock with colors
* Make the arguments less chunky / more concise * Make the arguments less chunky / more concise
* Let the user specify 3 colors and have it generate shades based off them * Let the user specify 3 colors and have it generate shades based off them
* Rainbow mode / random color mode? * Rainbow mode / random color mode?
* fix up the man page

23
unlock_indicator.c

@ -69,6 +69,8 @@ extern char bshlcolor[9];
extern char separatorcolor[9]; extern char separatorcolor[9];
extern int internal_line_source; extern int internal_line_source;
extern int screen_number;
/* Whether the failed attempts should be displayed. */ /* Whether the failed attempts should be displayed. */
extern bool show_failed_attempts; extern bool show_failed_attempts;
/* Number of failed unlock attempts. */ /* Number of failed unlock attempts. */
@ -416,12 +418,21 @@ xcb_pixmap_t draw_image(uint32_t *resolution) {
if (xr_screens > 0) { if (xr_screens > 0) {
/* Composite the unlock indicator in the middle of each screen. */ /* Composite the unlock indicator in the middle of each screen. */
for (int screen = 0; screen < xr_screens; screen++) { // excuse me, just gonna hack something in right here
int x = (xr_resolutions[screen].x + ((xr_resolutions[screen].width / 2) - (button_diameter_physical / 2))); if (screen_number != -1 && screen_number < xr_screens) {
int y = (xr_resolutions[screen].y + ((xr_resolutions[screen].height / 2) - (button_diameter_physical / 2))); int x = (xr_resolutions[screen_number].x + ((xr_resolutions[screen_number].width / 2) - (button_diameter_physical / 2)));
cairo_set_source_surface(xcb_ctx, output, x, y); int y = (xr_resolutions[screen_number].y + ((xr_resolutions[screen_number].height / 2) - (button_diameter_physical / 2)));
cairo_rectangle(xcb_ctx, x, y, button_diameter_physical, button_diameter_physical); cairo_set_source_surface(xcb_ctx, output, x, y);
cairo_fill(xcb_ctx); cairo_rectangle(xcb_ctx, x, y, button_diameter_physical, button_diameter_physical);
cairo_fill(xcb_ctx); }
else {
for (int screen = 0; screen < xr_screens; screen++) {
int x = (xr_resolutions[screen].x + ((xr_resolutions[screen].width / 2) - (button_diameter_physical / 2)));
int y = (xr_resolutions[screen].y + ((xr_resolutions[screen].height / 2) - (button_diameter_physical / 2)));
cairo_set_source_surface(xcb_ctx, output, x, y);
cairo_rectangle(xcb_ctx, x, y, button_diameter_physical, button_diameter_physical);
cairo_fill(xcb_ctx);
}
} }
} else { } else {
/* We have no information about the screen sizes/positions, so we just /* We have no information about the screen sizes/positions, so we just

Loading…
Cancel
Save