configuration optimized for menu position and some minor fixes

This commit is contained in:
mrdotx 2021-07-30 20:24:59 +02:00
parent 4e5c00ea38
commit 431d99aab6
No known key found for this signature in database
GPG Key ID: 433F70E636E6EB87
4 changed files with 87 additions and 80 deletions

3
README
View File

@ -33,9 +33,7 @@ To use pinentry-dmenu add in `~/.gnupg/gpg-agent.conf`:
The config is located in `~/.gnupg/pinentry-dmenu.conf`. The config is located in `~/.gnupg/pinentry-dmenu.conf`.
monitor = -1; monitor = -1;
center = false;
center_width = 1024; center_width = 1024;
bottom = false;
embedded = false; embedded = false;
line_height = 22; line_height = 22;
border_width = 2; border_width = 2;
@ -48,6 +46,7 @@ select_fg_alpha = 255;
select_bg_alpha = 255; select_bg_alpha = 255;
desc_fg_alpha = 255; desc_fg_alpha = 255;
desc_bg_alpha = 230; desc_bg_alpha = 230;
position = "center";
font = "DejaVuSansMono Nerd Font:pixelsize=16:antialias=true:autohint=true"; font = "DejaVuSansMono Nerd Font:pixelsize=16:antialias=true:autohint=true";
prompt = ""; prompt = "";
asterisk = "*"; asterisk = "*";

View File

@ -2,9 +2,7 @@
/* Default settings; can be overriden by pinentry-dmenu.conf */ /* Default settings; can be overriden by pinentry-dmenu.conf */
static unsigned int mon = -1; static unsigned int mon = -1;
static unsigned int center = 0;
static unsigned int centerwidth = 1024; static unsigned int centerwidth = 1024;
static unsigned int bottom = 0;
static unsigned int embedded = 0; static unsigned int embedded = 0;
static unsigned int lineheight = 22; static unsigned int lineheight = 22;
static unsigned int borderwidth = 2; static unsigned int borderwidth = 2;
@ -18,6 +16,7 @@ static unsigned int alphas[SchemeLast][2] = {
[SchemeDesc] = { 255, 230 }, [SchemeDesc] = { 255, 230 },
}; };
static const char *position = "center";
static const char *fonts[] = { static const char *fonts[] = {
"DejaVuSansMono Nerd Font:pixelsize=16:antialias=true:autohint=true" "DejaVuSansMono Nerd Font:pixelsize=16:antialias=true:autohint=true"
}; };

View File

@ -25,31 +25,25 @@ You can change the path to the config file with the environment variable
.SH OPTIONS .SH OPTIONS
.TP .TP
.BI "monitor =" " -1" .BI "monitor = " "-1"
pinentry-dmenu is displayed on the monitor number supplied. Monitor numbers are starting from 0. pinentry-dmenu is displayed on the monitor number supplied. Monitor numbers are starting from 0.
.TP .TP
.BI "center =" " false" .BI "center_width = " "1024"
pinentry-dmenu appears in the center of the screen.
.TP
.BI "center_width =" " 1024"
Defines the width for the 'center' menu. Defines the width for the 'center' menu.
.TP .TP
.BI "bottom =" " false" .BI "embedded = " "false"
pinentry-dmenu appears at the bottom of the screen.
.TP
.BI "embedded =" " false"
Embed into window. Embed into window.
.TP .TP
.BI "line_height =" " 22" .BI "line_height = " "22"
Defines menu line of at least 'line_height' pixels tall. Defines menu line of at least 'line_height' pixels tall.
.TP .TP
.BI "border_width =" " 2" .BI "border_width = " "2"
Defines the border width for the menu. Defines the border width for the menu.
.TP .TP
.BI "min_password_length =" " 32" .BI "min_password_length = " "32"
The minimal space of the password field. This value has affect to the description field after the password field. The minimal space of the password field. This value has affect to the description field after the password field.
.TP .TP
.BI "prompt_fg_alpha =" " 255" .BI "prompt_fg_alpha = " "255"
Defines the prompt foreground alpha value. Defines the prompt foreground alpha value.
Values between Values between
.IR 0 .IR 0
@ -57,61 +51,69 @@ Values between
.IR 255 .IR 255
(opaque) are supported. (opaque) are supported.
.TP .TP
.BI "prompt_bg_alpha =" " 255" .BI "prompt_bg_alpha = " "255"
Defines the prompt background alpha value. Defines the prompt background alpha value.
.TP .TP
.BI "normal_fg_alpha =" " 255" .BI "normal_fg_alpha = " "255"
Defines the normal foreground alpha value. Defines the normal foreground alpha value.
.TP .TP
.BI "normal_bg_alpha =" " 230" .BI "normal_bg_alpha = " "230"
Defines the normal background alpha value. Defines the normal background alpha value.
.TP .TP
.BI "select_fg_alpha =" " 255" .BI "select_fg_alpha = " "255"
Defines the selected foreground alpha value. Defines the selected foreground alpha value.
.TP .TP
.BI "select_bg_alpha =" " 255" .BI "select_bg_alpha = " "255"
Defines the selected background alpha value. Defines the selected background alpha value.
.TP .TP
.BI "desc_fg_alpha =" " 255" .BI "desc_fg_alpha = " "255"
Defines the description foreground alpha value. Defines the description foreground alpha value.
.TP .TP
.BI "desc_bg_alpha =" " 230" .BI "desc_bg_alpha = " "230"
Defines the description background alpha value. Defines the description background alpha value.
.TP .TP
.BI "font =" " DejaVuSansMono Nerd Font:pixelsize=16:antialias=true:autohint=true" .BI "position = " """center"""
Defines the osition of the menu.
.IR bottom ,
.I center
and
.I top
are supported.
.TP
.BI "font = " """DejaVuSansMono Nerd Font:pixelsize=16:antialias=true:autohint=true"""
Defines the font or font set used. Defines the font or font set used.
.TP .TP
.BI "prompt =" " """" .BI "prompt = " """"""
Defines the prompt to be displayed to the left of the input field. Defines the prompt to be displayed to the left of the input field.
.TP .TP
.BI "asterisk =" " *" .BI "asterisk = " """*"""
Defines the symbol which is showed for each typed character. Defines the symbol which is showed for each typed character.
.TP .TP
.BI "prompt_fg =" " #cccccc" .BI "prompt_fg = " """#cccccc"""
Defines the prompt foreground color. Defines the prompt foreground color.
.IR #RGB , .IR #RGB ,
.I #RRGGBB .I #RRGGBB
and X color names are supported. and X color names are supported.
.TP .TP
.BI "prompt_bg =" " #4185d7" .BI "prompt_bg = " """#4185d7"""
Defines the prompt background color. Defines the prompt background color.
.TP .TP
.BI "normal_fg =" " #cccccc" .BI "normal_fg = " """#cccccc"""
Defines the normal foreground color. Defines the normal foreground color.
.TP .TP
.BI "normal_bg =" " #000000" .BI "normal_bg = " """#000000"""
Defines the normal background color. Defines the normal background color.
.TP .TP
.BI "select_fg =" " #ffffff" .BI "select_fg = " """#ffffff"""
Defines the selected foreground color. Defines the selected foreground color.
.TP .TP
.BI "select_bg =" " #4185d7" .BI "select_bg = " """#4185d7"""
Defines the selected background color. Defines the selected background color.
.TP .TP
.BI "desc_fg =" " #cccccc" .BI "desc_fg = " """#cccccc"""
Defines the description foreground color. Defines the description foreground color.
.TP .TP
.BI "desc_bg =" " #000000" .BI "desc_bg = " """#000000"""
Defines the description background color. Defines the description background color.
.SH USAGE .SH USAGE
@ -227,9 +229,7 @@ Paste from primary X selection
.\} .\}
.nf .nf
monitor = -1; monitor = -1;
center = false;
center_width = 1024; center_width = 1024;
bottom = false;
embedded = false; embedded = false;
line_height = 22; line_height = 22;
border_width = 2; border_width = 2;
@ -242,6 +242,7 @@ select_fg_alpha = 255;
select_bg_alpha = 255; select_bg_alpha = 255;
desc_fg_alpha = 255; desc_fg_alpha = 255;
desc_bg_alpha = 230; desc_bg_alpha = 230;
position = "center";
font = "DejaVuSansMono Nerd Font:pixelsize=16:antialias=true:autohint=true"; font = "DejaVuSansMono Nerd Font:pixelsize=16:antialias=true:autohint=true";
prompt = ""; prompt = "";
asterisk = "*"; asterisk = "*";

View File

@ -48,6 +48,8 @@ static int lrpad;
static size_t cursor; static size_t cursor;
static int screen; static int screen;
static int bottom = 0, center = 0;
static char* pin; static char* pin;
static int pin_len; static int pin_len;
static char* pin_repeat; static char* pin_repeat;
@ -272,7 +274,7 @@ drawwin(void) {
drw_setscheme(drw, scheme[SchemeDesc]); drw_setscheme(drw, scheme[SchemeDesc]);
if (center) { if (center) {
drw_text(drw, ppromptw, lineheight, centerwidth, drw_text(drw, promptw + ppromptw, lineheight, centerwidth,
bh + borderwidth, lrpad / 2, bh + borderwidth, lrpad / 2,
pinentry_info->description, 0); pinentry_info->description, 0);
} else { } else {
@ -804,15 +806,9 @@ main(int argc, char *argv[]) {
if (config_lookup_int(&cfg, "monitor", &val)) { if (config_lookup_int(&cfg, "monitor", &val)) {
mon = val; mon = val;
} }
if (config_lookup_bool(&cfg, "center", &bval)) {
center = bval;
}
if (config_lookup_int(&cfg, "center_width", &val)) { if (config_lookup_int(&cfg, "center_width", &val)) {
centerwidth = val; centerwidth = val;
} }
if (config_lookup_bool(&cfg, "bottom", &bval)) {
bottom = bval;
}
if (config_lookup_bool(&cfg, "embedded", &bval)) { if (config_lookup_bool(&cfg, "embedded", &bval)) {
embedded = bval; embedded = bval;
} }
@ -822,6 +818,33 @@ main(int argc, char *argv[]) {
if (config_lookup_int(&cfg, "border_width", &val)) { if (config_lookup_int(&cfg, "border_width", &val)) {
borderwidth = val; borderwidth = val;
} }
if (config_lookup_int(&cfg, "prompt_fg_alpha", &val)) {
alphas[SchemePrompt][0] = val;
}
if (config_lookup_int(&cfg, "prompt_bg_alpha", &val)) {
alphas[SchemePrompt][1] = val;
}
if (config_lookup_int(&cfg, "normal_fg_alpha", &val)) {
alphas[SchemeNormal][0] = val;
}
if (config_lookup_int(&cfg, "normal_bg_alpha", &val)) {
alphas[SchemeNormal][1] = val;
}
if (config_lookup_int(&cfg, "select_fg_alpha", &val)) {
alphas[SchemeSelect][0] = val;
}
if (config_lookup_int(&cfg, "select_bg_alpha", &val)) {
alphas[SchemeSelect][1] = val;
}
if (config_lookup_int(&cfg, "desc_fg_alpha", &val)) {
alphas[SchemeDesc][0] = val;
}
if (config_lookup_int(&cfg, "desc_bg_alpha", &val)) {
alphas[SchemeDesc][1] = val;
}
if (config_lookup_string(&cfg, "position", &str)) {
position = str;
}
if (config_lookup_string(&cfg, "font", &str)) { if (config_lookup_string(&cfg, "font", &str)) {
fonts[0] = str; fonts[0] = str;
} }
@ -858,30 +881,6 @@ main(int argc, char *argv[]) {
if (config_lookup_string(&cfg, "desc_bg", &str)) { if (config_lookup_string(&cfg, "desc_bg", &str)) {
colors[SchemeDesc][ColBg] = str; colors[SchemeDesc][ColBg] = str;
} }
if (config_lookup_int(&cfg, "prompt_fg_alpha", &val)) {
alphas[SchemePrompt][0] = val;
}
if (config_lookup_int(&cfg, "prompt_bg_alpha", &val)) {
alphas[SchemePrompt][1] = val;
}
if (config_lookup_int(&cfg, "normal_fg_alpha", &val)) {
alphas[SchemeNormal][0] = val;
}
if (config_lookup_int(&cfg, "normal_bg_alpha", &val)) {
alphas[SchemeNormal][1] = val;
}
if (config_lookup_int(&cfg, "select_fg_alpha", &val)) {
alphas[SchemeSelect][0] = val;
}
if (config_lookup_int(&cfg, "select_bg_alpha", &val)) {
alphas[SchemeSelect][1] = val;
}
if (config_lookup_int(&cfg, "desc_fg_alpha", &val)) {
alphas[SchemeDesc][0] = val;
}
if (config_lookup_int(&cfg, "desc_bg_alpha", &val)) {
alphas[SchemeDesc][1] = val;
}
} else if ((str = config_error_file(&cfg))) { } else if ((str = config_error_file(&cfg))) {
fprintf(stderr, "%s:%d: %s\n", config_error_file(&cfg), fprintf(stderr, "%s:%d: %s\n", config_error_file(&cfg),
config_error_line(&cfg), config_error_text(&cfg)); config_error_line(&cfg), config_error_text(&cfg));
@ -890,6 +889,15 @@ main(int argc, char *argv[]) {
printf("No config file found. Use defaults.\n"); printf("No config file found. Use defaults.\n");
} }
if (0 == strcmp(position, "center")) {
center = 1;
bottom = 0;
}
if (0 == strcmp(position, "bottom")) {
center = 0;
bottom = 1;
}
pinentry_init("pinentry-dmenu"); pinentry_init("pinentry-dmenu");
pinentry_parse_opts(argc, argv); pinentry_parse_opts(argc, argv);