diff --git a/LICENSE b/LICENSE index 6ed8ad3..3afd28e 100644 --- a/LICENSE +++ b/LICENSE @@ -8,8 +8,8 @@ MIT/X Consortium License © 2009 Markus Schnalke © 2009 Evan Gates © 2010-2012 Connor Lane Smith -© 2014-2019 Hiltjo Posthuma -© 2015-2018 Quentin Rameau +© 2014-2020 Hiltjo Posthuma +© 2015-2019 Quentin Rameau Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), diff --git a/Makefile b/Makefile index 069b76f..b42c96e 100644 --- a/Makefile +++ b/Makefile @@ -17,9 +17,6 @@ options: .c.o: $(CC) -c $(CFLAGS) $< -config.h: - cp config.def.h $@ - $(OBJ): arg.h config.h config.mk drw.h dmenu: dmenu.o drw.o util.o @@ -33,8 +30,8 @@ clean: dist: clean mkdir -p dmenu-$(VERSION) - cp LICENSE Makefile README arg.h config.def.h config.mk dmenu.1\ - drw.h util.h dmenu_run stest.1 $(SRC)\ + cp LICENSE Makefile README arg.h config.h config.mk dmenu.1\ + drw.h util.h dmenu_path dmenu_run stest.1 $(SRC)\ dmenu-$(VERSION) tar -cf dmenu-$(VERSION).tar dmenu-$(VERSION) gzip dmenu-$(VERSION).tar @@ -42,8 +39,9 @@ dist: clean install: all mkdir -p $(DESTDIR)$(PREFIX)/bin - cp -f dmenu dmenu_run stest $(DESTDIR)$(PREFIX)/bin + cp -f dmenu dmenu_path dmenu_run stest $(DESTDIR)$(PREFIX)/bin chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu + chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_path chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_run chmod 755 $(DESTDIR)$(PREFIX)/bin/stest mkdir -p $(DESTDIR)$(MANPREFIX)/man1 @@ -54,6 +52,7 @@ install: all uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/dmenu\ + $(DESTDIR)$(PREFIX)/bin/dmenu_path\ $(DESTDIR)$(PREFIX)/bin/dmenu_run\ $(DESTDIR)$(PREFIX)/bin/stest\ $(DESTDIR)$(MANPREFIX)/man1/dmenu.1\ diff --git a/config.h b/config.h index 2637fae..63d2e94 100644 --- a/config.h +++ b/config.h @@ -1,6 +1,17 @@ /* See LICENSE file for copyright and license details. */ /* Default settings; can be overriden by command line. */ +static int instant = 0; +static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */ +/* -fn option overrides fonts[0]; default X11 font or font set */ +static const char *fonts[] = { + "monospace:size=13", + "IPAGothic:size=13", + "symbola:size=13"}; + +static const char *prompt = NULL; /* -p option; prompt to the left of input field */ + +// NORD COLORS: #define bblack "#000000" #define nord0 "#2E3440" #define nord1 "#3B4252" @@ -18,27 +29,14 @@ #define nord13 "#EBCB8B" #define nord14 "#A3BE8C" #define nord15 "#B48EAD" - - -static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */ -/* -fn option overrides fonts[0]; default X11 font or font set */ -static const char *fonts[] = { - "monospace:size=13", - "IPAGothic:size=13", - "symbola:size=13"}; - -static const char *prompt = NULL; /* -p option; prompt to the left of input field */ - static const char *colors[SchemeLast][2] = { /* fg bg */ [SchemeNorm] = { nord4 , nord0 }, - [SchemeSel] = { nord6, nord10 }, + [SchemeSel] = { nord6, nord10 }, }; - /* -l option; if nonzero, dmenu uses vertical list with given number of lines */ static unsigned int lines = 0; -static int instant = 0; static int sidepad = 20; static int vertpad = 10; /* diff --git a/config.mk b/config.mk index 0929b4a..05d5a3e 100644 --- a/config.mk +++ b/config.mk @@ -1,5 +1,5 @@ # dmenu version -VERSION = 4.9 +VERSION = 5.0 # paths PREFIX = /usr/local diff --git a/dmenu.1 b/dmenu.1 index bdd25ea..29bdf7f 100644 --- a/dmenu.1 +++ b/dmenu.1 @@ -48,7 +48,7 @@ is faster, but will lock up X until stdin reaches end\-of\-file. dmenu matches menu items case insensitively. .TP .B \-n -dmenu instantly selects if only one match +dmenu instantly selects if only one match. .TP .BI \-l " lines" dmenu lists items vertically, with the given number of lines. diff --git a/dmenu.c b/dmenu.c index 5400670..75cc460 100644 --- a/dmenu.c +++ b/dmenu.c @@ -19,10 +19,6 @@ #include "drw.h" #include "util.h" -//static const int vertpad = 10; -//static const int sidepad = 20; - - /* macros */ #define INTERSECT(x,y,w,h,r) (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \ * MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org))) @@ -272,7 +268,6 @@ match(void) exit(0); } - calcoffsets(); } @@ -565,9 +560,14 @@ run(void) XEvent ev; while (!XNextEvent(dpy, &ev)) { - if (XFilterEvent(&ev, None)) + if (XFilterEvent(&ev, win)) continue; switch(ev.type) { + case DestroyNotify: + if (ev.xdestroywindow.window != win) + break; + cleanup(); + exit(1); case Expose: if (ev.xexpose.count == 0) drw_map(drw, win, 0, 0, mw, mh); @@ -671,15 +671,17 @@ setup(void) CWOverrideRedirect | CWBackPixel | CWEventMask, &swa); XSetClassHint(dpy, win, &ch); - /* open input methods */ - xim = XOpenIM(dpy, NULL, NULL, NULL); + + /* input methods */ + if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) + die("XOpenIM failed: could not open input device"); + xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, win, XNFocusWindow, win, NULL); XMapRaised(dpy, win); - XSetInputFocus(dpy, win, RevertToParent, CurrentTime); if (embed) { - XSelectInput(dpy, parentwin, FocusChangeMask); + XSelectInput(dpy, parentwin, FocusChangeMask | SubstructureNotifyMask); if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) { for (i = 0; i < du && dws[i] != win; ++i) XSelectInput(dpy, dws[i], FocusChangeMask); @@ -745,8 +747,6 @@ main(int argc, char *argv[]) if (!setlocale(LC_CTYPE, "") || !XSupportsLocale()) fputs("warning: no locale support\n", stderr); - if (!XSetLocaleModifiers("")) - fputs("warning: no locale modifiers support\n", stderr); if (!(dpy = XOpenDisplay(NULL))) die("cannot open display"); screen = DefaultScreen(dpy); diff --git a/dmenu_path b/dmenu_path new file mode 100755 index 0000000..3a7cda7 --- /dev/null +++ b/dmenu_path @@ -0,0 +1,13 @@ +#!/bin/sh + +cachedir="${XDG_CACHE_HOME:-"$HOME/.cache"}" +cache="$cachedir/dmenu_run" + +[ ! -e "$cachedir" ] && mkdir -p "$cachedir" + +IFS=: +if stest -dqr -n "$cache" $PATH; then + stest -flx $PATH | sort -u | tee "$cache" +else + cat "$cache" +fi diff --git a/dmenu_run b/dmenu_run index dcaa8dd..02f68da 100755 --- a/dmenu_run +++ b/dmenu_run @@ -1,7 +1,7 @@ #!/bin/sh aliases=$HOME/.config/aliasrc -source $aliases +#. $HOME/.config/aliasrc termcmd="st -e" cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"} if [ -d "$cachedir" ]; then diff --git a/drw.c b/drw.c index 8fd1ca4..4cdbcbe 100644 --- a/drw.c +++ b/drw.c @@ -95,6 +95,7 @@ drw_free(Drw *drw) { XFreePixmap(drw->dpy, drw->drawable); XFreeGC(drw->dpy, drw->gc); + drw_fontset_free(drw->fonts); free(drw); }