personal config

This commit is contained in:
λmolinae 2025-06-22 22:21:48 -06:00
parent af6440da8f
commit 5a68bfbec1
7 changed files with 68 additions and 6 deletions

3
.gitignore vendored
View file

@ -1,4 +1,5 @@
mew
config.h
*.o
*-protocol.*
*.orig
*.rej

View file

@ -56,9 +56,10 @@ clean:
install: all
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp -f mew mew-run $(DESTDIR)$(PREFIX)/bin
cp -f mew mew-run pinentry-mew $(DESTDIR)$(PREFIX)/bin
chmod 755 $(DESTDIR)$(PREFIX)/bin/mew
chmod 755 $(DESTDIR)$(PREFIX)/bin/mew-run
chmod 755 $(DESTDIR)$(PREFIX)/bin/pinentry-mew
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
sed "s/VERSION/$(VERSION)/g" < mew.1 > $(DESTDIR)$(MANPREFIX)/man1/mew.1
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/mew.1
@ -66,6 +67,7 @@ install: all
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/mew \
$(DESTDIR)$(PREFIX)/bin/mew-run \
$(DESTDIR)$(PREFIX)/bin/pinentry-mew \
$(DESTDIR)$(MANPREFIX)/man1/mew.1
.PHONY: all clean install uninstall

View file

@ -17,6 +17,9 @@ static const char *output_name = NULL;
/* -l option; if nonzero, use vertical list with given number of lines */
static unsigned int lines = 0;
/* -p option; display input as asterisks */
static int passwd = 0;
/*
* Characters not considered part of a word while deleting words
* for example: " /?\"&[]"

22
config.h Normal file
View file

@ -0,0 +1,22 @@
/* See LICENSE file for copyright and license details. */
/* Default settings; can be overriden by command line. */
static int top = 1; /* -b option; if 0, appear at bottom */
static const char *fonts[] = { "Inconsolata:size=14" }; /* -f option overrides fonts[0] */
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
#include "/home/amolinae/.cache/wal/colors-wal-mew.h"
/* -m option; if provided, use that output instead of default output */
static const char *output_name = NULL;
/* -l option; if nonzero, use vertical list with given number of lines */
static unsigned int lines = 0;
/* -p option; display input as asterisks */
static int passwd = 0;
/*
* Characters not considered part of a word while deleting words
* for example: " /?\"&[]"
*/
static const char worddelimiters[] = " ";

6
mew.1
View file

@ -3,7 +3,7 @@
mew \- menu for wayland
.SH SYNOPSIS
.B mew
.RB [ \-beiv ]
.RB [ \-beivP ]
.RB [ \-l
.IR lines ]
.RB [ \-o
@ -46,6 +46,10 @@ passing focus to the application ran.
.B \-i
matches menu items case insensitively.
.TP
.B \-P
do not directly display the keyboard input, but instead replace it with asterisks.
All data from stdin will be ignored.
.TP
.BI \-l " lines"
lists item vertically, with the given number of lines.
.TP

20
mew.c
View file

@ -280,6 +280,7 @@ drawmenu(void)
unsigned int curpos;
struct item *item;
int x = 0, y = 0, w;
char *censort;
DrwBuf *buf;
errno = 0;
@ -297,7 +298,13 @@ drawmenu(void)
/* draw input field */
w = (lines > 0 || !matches) ? mw - x : inputw;
drwl_setscheme(drw, colors[SchemeNorm]);
drwl_text(drw, x, 0, w, bh, lrpad / 2, text, 0);
if (passwd) {
censort = calloc(1, sizeof(text));
memset(censort, '*', strlen(text));
drwl_text(drw, x, 0, w, bh, lrpad / 2, censort, 0);
free(censort);
} else
drwl_text(drw, x, 0, w, bh, lrpad / 2, text, 0);
curpos = TEXTW(text) - TEXTW(&text[cursor]);
if ((curpos += lrpad / 2 - 1) < w) {
@ -908,6 +915,11 @@ readstdin(void)
size_t i, itemsiz = 0, linesiz = 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, &linesiz, stdin)) != -1; i++) {
if (i + 1 >= itemsiz) {
@ -1003,7 +1015,7 @@ setup(void)
static void
usage(void)
{
die("usage: mew [-beiv] [-l lines] [-p prompt] [-f font] [-o output]\n"
die("usage: mew [-beivP] [-l lines] [-p prompt] [-f font] [-o output]\n"
" [-nb color] [-nf color] [-sb color] [-sf color]");
}
@ -1024,7 +1036,9 @@ main(int argc, char *argv[])
else if (!strcmp(argv[i], "-i")) {
fstrncmp = strncasecmp;
fstrstr = cistrstr;
} else if (i + 1 == argc)
} else if (!strcmp(argv[i], "-P"))
passwd = 1;
else if (i + 1 == argc)
usage();
else if (!strcmp(argv[i], "-l"))
lines = atoi(argv[++i]);

16
pinentry-mew Executable file
View file

@ -0,0 +1,16 @@
#!/bin/sh
# ported from pinentry-dmenu
echo 'OK Pleased to meet you'
while read -r stdin; do
case $stdin in
*BYE*) exit ;;
*SETDESC*) KEYNAME=${stdin#*:%0A%22}; KEYNAME=${KEYNAME%\%22\%0A*}; KEYID=${stdin#*ID }; KEYID=${KEYID%,*} ;;
*GETPIN*) printf 'D %s\n' $(mew -P -p "pinentry: $KEYNAME ($KEYID) ${error:+$error }$prompt") ;;
*SETERROR*) error="${stdin#*\ }"; ;;
*SETPROMPT*) prompt="${stdin#*\ }"; ;;
esac
echo OK
done