~adnano/wmenu-devel

Support password prompts v1 SUPERSEDED

sinanmohd: 1
 Support password prompts

 2 files changed, 14 insertions(+), 5 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~adnano/wmenu-devel/patches/39794/mbox | git am -3
Learn more about email & git

[PATCH] Support password prompts Export this patch

---
Hi,

this patch allows wmenu to be used as a password prompt. can be
used with sudo and other programmes. this flag is really helpful
for scripts that rely on wmenu for user input. i use it for my vpn scipt
https://git.sinanmohd.com/sds/tree/vpn which relies on
https://git.sinanmohd.com/sds/tree/daskpass.

 docs/wmenu.1.scd |  6 ++++--
 main.c           | 13 ++++++++++---
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/docs/wmenu.1.scd b/docs/wmenu.1.scd
index f532b21..647ffb5 100644
--- a/docs/wmenu.1.scd
+++ b/docs/wmenu.1.scd
@@ -6,7 +6,7 @@ wmenu - dynamic menu for Wayland

# SYNOPSIS

*wmenu* [-biv] \
*wmenu* [-bivP] \
  [-f _font_] \
  [-l _lines_] \
  [-o _output_] \
@@ -33,6 +33,9 @@ to those matching the tokens in the input.
*-v*
	prints version information to stdout, then exits.

*-P*
	wmenu will hide keyboard input.

*-f* _font_
	defines the font used. For more information, see
	https://docs.gtk.org/Pango/type_func.FontDescription.from_string.html
@@ -144,4 +147,3 @@ arrow keys, page up, page down, home, and end.

|[ *C-w*
:[ Delete word left

diff --git a/main.c b/main.c
index 496521f..f441873 100644
--- a/main.c
+++ b/main.c
@@ -68,6 +68,7 @@ struct menu_state {
	int (*fstrncmp)(const char *, const char *, size_t);
	char *font;
	bool vertical;
	bool passprompt;
	int lines;
	char *prompt;
	uint32_t background, foreground;
@@ -771,7 +772,8 @@ void keypress(struct menu_state *state, enum wl_keyboard_key_state key_state,
	default:
		if (xkb_keysym_to_utf8(sym, buf, 8)) {
			insert(state, buf, strnlen(buf, 8));
			render_frame(state);
			if (!state->passprompt)
				render_frame(state);
		}
	}
}
@@ -1082,6 +1084,7 @@ int main(int argc, char **argv) {
		.fstrncmp = strncmp,
		.font = "monospace 10",
		.vertical = false,
		.passprompt = false,
		.background = 0x222222ff,
		.foreground = 0xbbbbbbff,
		.promptbg = 0x005577ff,
@@ -1092,11 +1095,11 @@ int main(int argc, char **argv) {
	};

	const char *usage =
		"Usage: wmenu [-biv] [-f font] [-l lines] [-o output] [-p prompt]\n"
		"Usage: wmenu [-bivP] [-f font] [-l lines] [-o output] [-p prompt]\n"
		"\t[-N color] [-n color] [-M color] [-m color] [-S color] [-s color]\n";

	int opt;
	while ((opt = getopt(argc, argv, "bhivf:l:o:p:N:n:M:m:S:s:")) != -1) {
	while ((opt = getopt(argc, argv, "bhivPf:l:o:p:N:n:M:m:S:s:")) != -1) {
		switch (opt) {
		case 'b':
			state.bottom = true;
@@ -1114,6 +1117,9 @@ int main(int argc, char **argv) {
			state.vertical = true;
			state.lines = atoi(optarg);
			break;
		case 'P':
			state.passprompt = true;
			break;
		case 'o':
			state.output_name = optarg;
			break;
@@ -1206,3 +1212,4 @@ int main(int argc, char **argv) {
	}
	return EXIT_SUCCESS;
}

--
2.40.0
Hi, thanks for the patch!

The goal of wmenu is to have feature parity with dmenu. I'm hesitant to
introduce features that aren't present in dmenu.