mirror of
https://github.com/Raymo111/i3lock-color.git
synced 2024-12-02 14:05:43 -05:00
add option for single-display unlock indicator
This commit is contained in:
parent
177024ddc0
commit
ed326ee463
4 changed files with 26 additions and 7 deletions
|
@ -30,6 +30,7 @@ Many little improvements have been made to i3lock over time:
|
|||
- `--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
|
||||
- `-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.
|
||||
|
||||
- You can specify whether i3lock should bell upon a wrong password.
|
||||
|
|
8
i3lock.c
8
i3lock.c
|
@ -58,6 +58,8 @@ char textcolor[9] = "000000ff";
|
|||
char keyhlcolor[9] = "33db00ff";
|
||||
char bshlcolor[9] = "db3300ff";
|
||||
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 */
|
||||
int internal_line_source = 0;
|
||||
|
||||
|
@ -789,6 +791,7 @@ int main(int argc, char *argv[]) {
|
|||
{"line-uses-ring", no_argument, NULL, 'r'},
|
||||
{"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 */
|
||||
{"screen", required_argument, NULL, 'S'},
|
||||
{"ignore-empty-password", no_argument, NULL, 'e'},
|
||||
{"inactivity-timeout", required_argument, NULL, 'I'},
|
||||
{"show-failed-attempts", no_argument, NULL, 'f'},
|
||||
|
@ -799,7 +802,7 @@ int main(int argc, char *argv[]) {
|
|||
if ((username = pw->pw_name) == NULL)
|
||||
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) {
|
||||
switch (o) {
|
||||
case 'v':
|
||||
|
@ -865,6 +868,9 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
internal_line_source = 2;
|
||||
break;
|
||||
case 'S':
|
||||
screen_number = atoi(optarg);
|
||||
break;
|
||||
case 0:
|
||||
if (strcmp(longopts[optind].name, "debug") == 0)
|
||||
debug_mode = true;
|
||||
|
|
1
todo.md
1
todo.md
|
@ -4,3 +4,4 @@ st for i3lock with colors
|
|||
* Make the arguments less chunky / more concise
|
||||
* Let the user specify 3 colors and have it generate shades based off them
|
||||
* Rainbow mode / random color mode?
|
||||
* fix up the man page
|
||||
|
|
|
@ -69,6 +69,8 @@ extern char bshlcolor[9];
|
|||
extern char separatorcolor[9];
|
||||
extern int internal_line_source;
|
||||
|
||||
extern int screen_number;
|
||||
|
||||
/* Whether the failed attempts should be displayed. */
|
||||
extern bool show_failed_attempts;
|
||||
/* Number of failed unlock attempts. */
|
||||
|
@ -416,12 +418,21 @@ xcb_pixmap_t draw_image(uint32_t *resolution) {
|
|||
|
||||
if (xr_screens > 0) {
|
||||
/* Composite the unlock indicator in the middle of each screen. */
|
||||
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);
|
||||
// excuse me, just gonna hack something in right here
|
||||
if (screen_number != -1 && screen_number < xr_screens) {
|
||||
int x = (xr_resolutions[screen_number].x + ((xr_resolutions[screen_number].width / 2) - (button_diameter_physical / 2)));
|
||||
int y = (xr_resolutions[screen_number].y + ((xr_resolutions[screen_number].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 {
|
||||
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 {
|
||||
/* We have no information about the screen sizes/positions, so we just
|
||||
|
|
Loading…
Reference in a new issue