commit - ec4e7034a943f389ff098aafbbe9f9de5908934b
commit + 125e80b814d7008855e62cbb081204803e8c7061
blob - 1f2ccc071a4c245fd66da8f3c13d65c5a6b9dc6e
blob + 70ee9a744336717ed4d5fce61072cfee6f81ac55
--- TODO
+++ TODO
# Fix
- dwm: XKeycodeToKeysum
-# Patch
-- dmenu: passwords
-
# Refactor
- split common code into a library (drw.c)
- pinentry code is ugly AF, replace it with something better
blob - 037c667f2c65babef293b5cd3a5c119b21dd555e
blob + da01b4c1f2b579312f717f99393879f3a678592f
--- dmenu/config.h
+++ dmenu/config.h
* for example: " /?\"&[]"
*/
static const char worddelimiters[] = " ";
+
+/* Character to be shown, when entering a password. */
+static char pwcensorchar = '*';
blob - 323f93cf88eee5bd4878cf78cf40d9677277916c
blob + 762f7071c23f0a2bc3b2c872695fdb9cdc5317fd
--- dmenu/dmenu.1
+++ dmenu/dmenu.1
dmenu \- dynamic menu
.SH SYNOPSIS
.B dmenu
-.RB [ \-bfiv ]
+.RB [ \-bfivP ]
.RB [ \-l
.IR lines ]
.RB [ \-m
.B \-i
dmenu matches menu items case insensitively.
.TP
+.B \-P
+dmenu will not directly display the keyboard input, but instead replace it with dots. All data from stdin will be ignored.
+.TP
.BI \-l " lines"
dmenu lists items vertically, with the given number of lines.
.TP
blob - c6dc01ea4ac34d82b4f6a04d0a43de79ad1b9c14
blob + fa3606efa7e0841ca21c9e66f16d168406ba2048
--- dmenu/dmenu.c
+++ dmenu/dmenu.c
static char text[BUFSIZ] = "";
static char *embed;
static int bh, mw, mh;
-static int inputw = 0, promptw;
+static int inputw = 0, promptw, passwd = 0;
static int lrpad; /* sum of left and right padding */
static size_t cursor;
static struct item *items = NULL;
unsigned int curpos;
struct item *item;
int x = 0, y = 0, w;
+ char *censort;
drw_setscheme(drw, scheme[SchemeNorm]);
drw_rect(drw, 0, 0, mw, mh, 1, 1);
/* draw input field */
w = (lines > 0 || !matches) ? mw - x : inputw;
drw_setscheme(drw, scheme[SchemeNorm]);
- drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0);
+ if (passwd) {
+ censort = ecalloc(1, sizeof(text));
+ memset(censort, pwcensorchar, strlen(text));
+ drw_text(drw, x, 0, w, bh, lrpad / 2, censort, 0);
+ free(censort);
+ } else drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0);
curpos = TEXTW(text) - TEXTW(&text[cursor]);
if ((curpos += lrpad / 2 - 1) < w) {
size_t i, junk, size = 0;
ssize_t len;
+ if (passwd) {
+ inputw = lines = 0;
+ return;
+ }
+
/* read each line from stdin and add it to the item list */
for (i = 0; (len = getline(&line, &junk, stdin)) != -1; i++, line = NULL) {
if (i + 1 >= size / sizeof *items)
static void
usage(void)
{
- die("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
+ die("usage: dmenu [-bfivP] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
" [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
}
else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
fstrncmp = strncasecmp;
fstrstr = cistrstr;
- } else if (i + 1 == argc)
+ } else if (!strcmp(argv[i], "-P")) /* is the input a password */
+ passwd = 1;
+ else if (i + 1 == argc)
usage();
/* these options take one argument */
else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */