---
Makefile | 3 +++
config.def.h | 3 ++-
dwm-init | 9 +++++++++
dwm.c | 12 ++++++++++++
4 files changed, 26 insertions(+), 1 deletion(-)
create mode 100644 dwm-init
diff --git a/Makefile b/Makefile
index 77bcbc0..be24b24 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -40,12 +40,15 @@ install: all
mkdir -p ${DESTDIR}${PREFIX}/bin
cp -f dwm ${DESTDIR}${PREFIX}/bin
chmod 755 ${DESTDIR}${PREFIX}/bin/dwm
+ cp -f dwm-init ${DESTDIR}${PREFIX}/bin
+ chmod 755 ${DESTDIR}${PREFIX}/bin/dwm-init
mkdir -p ${DESTDIR}${MANPREFIX}/man1
sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1
chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1
uninstall:
rm -f ${DESTDIR}${PREFIX}/bin/dwm\
+ ${DESTDIR}${PREFIX}/bin/dwm-init\
${DESTDIR}${MANPREFIX}/man1/dwm.1
.PHONY: all options clean dist install uninstall
diff --git a/config.def.h b/config.def.h
index 1c0b587..a4d26da 100644
--- a/config.def.h
+++ b/config.def.h
_AT_@ -93,7 +93,8 @@ static Key keys[] = {
TAGKEYS( XK_7, 6)
TAGKEYS( XK_8, 7)
TAGKEYS( XK_9, 8)
- { MODKEY|ShiftMask, XK_q, quit, {0} },
+ { MODKEY|ShiftMask, XK_r, quit, {0} },
+ { MODKEY|ShiftMask, XK_q, quitnoreload, {0} },
};
/* button definitions */
diff --git a/dwm-init b/dwm-init
new file mode 100644
index 0000000..db111a3
--- /dev/null
+++ b/dwm-init
_AT_@ -0,0 +1,9 @@
+#!/bin/sh
+
+EXIT_NORELOAD=64
+# put stuff here to run once
+
+while true; do
+ dwm
+ [ $? = $EXIT_NORELOAD ] && break
+done
diff --git a/dwm.c b/dwm.c
index 9fd0286..b9feb50 100644
--- a/dwm.c
+++ b/dwm.c
_AT_@ -56,6 +56,7 @@
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
#define TAGMASK ((1 << LENGTH(tags)) - 1)
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
+#define EXIT_NORELOAD 64
/* enums */
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
_AT_@ -188,6 +189,7 @@ static Client *nexttiled(Client *c);
static void pop(Client *);
static void propertynotify(XEvent *e);
static void quit(const Arg *arg);
+static void quitnoreload(const Arg *arg);
static Monitor *recttomon(int x, int y, int w, int h);
static void resize(Client *c, int x, int y, int w, int h, int interact);
static void resizeclient(Client *c, int x, int y, int w, int h);
_AT_@ -268,6 +270,7 @@ static Display *dpy;
static Drw *drw;
static Monitor *mons, *selmon;
static Window root, wmcheckwin;
+static int noreload = 0;
/* configuration, allows nested code to access above variables */
#include "config.h"
_AT_@ -1252,6 +1255,13 @@ quit(const Arg *arg)
running = 0;
}
+void
+quitnoreload(const Arg *arg)
+{
+ noreload = 1;
+ running = 0;
+}
+
Monitor *
recttomon(int x, int y, int w, int h)
{
_AT_@ -1649,6 +1659,7 @@ spawn(const Arg *arg)
execvp(((char **)arg->v)[0], (char **)arg->v);
fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]);
perror(" failed");
+ if (noreload) exit(EXIT_NORELOAD);
exit(EXIT_SUCCESS);
}
}
_AT_@ -2148,5 +2159,6 @@ main(int argc, char *argv[])
run();
cleanup();
XCloseDisplay(dpy);
+ if (noreload) return EXIT_NORELOAD;
return EXIT_SUCCESS;
}
--
2.27.0
This archive was generated by hypermail 2.3.0 : Mon Jul 20 2020 - 10:24:34 CEST