On Tue, Dec 09, 2008 at 10:41:35AM -0700, Neale Pickett wrote:
> I very much like this patch. I realized right away that I would never
> again need to restart dwm when I work on my status script. When it
> dies, I can just start it up again without restarting DWM. Someone
> could even have multiple programs running to update the status text. It
> removes the need for the "readin" variable: you either set the property
> or you don't.
>
> The patch removes 39 SLOC:
gotta admit Neale has 2 points :)
i like the idea of not having to restart dwm when hacking on the status
script
conversely, when hacking on dwm itself, i like being able to restart dwm
without restarting my x session, yet i want the session to exit when dwm
exits, ie. "dwm & xterm" in .xsession is not what i want.
here is a "respawn" patch. it is most useful in conjunction with a
"local install" in the makefile, copying the newly built dwm binary over
the currently running one, inside my $HOME rather than in /usr/local
the patch costs 5 loc in the source + 1 loc in config.h
the patch is not completely portable due to use of ``environ''. i hope
that even the BSDs have that nowadays, but probably not through defining
_GNU_SOURCE, which is glibc specific.
cheers
--
Benoit Triquet <benoit.triquet at gmail.com>
.''`.
: :' : We are debian.org. Lower your prices, surrender your code.
`. `' We will add your hardware and software distinctiveness to
`- our own. Resistance is futile.
diff -ruN orig/dwm-5.3.1/config.def.h dwm-5.3.1/config.def.h
--- orig/dwm-5.3.1/config.def.h 2008-12-06 10:33:03.000000000 +0100
+++ dwm-5.3.1/config.def.h 2008-12-09 20:12:45.000000000 +0100
@@ -80,7 +80,8 @@
TAGKEYS( XK_7, 6)
TAGKEYS( XK_8, 7)
TAGKEYS( XK_9, 8)
- { MODKEY|ShiftMask, XK_q, quit, {0} },
+ { MODKEY|ShiftMask, XK_q, quit, {.i = 0 } },
+ { MODKEY|ShiftMask|ControlMask, XK_q, quit, {.i = 1 } },
};
/* button definitions */
diff -ruN orig/dwm-5.3.1/dwm.c dwm-5.3.1/dwm.c
--- orig/dwm-5.3.1/dwm.c 2008-12-06 10:33:03.000000000 +0100
+++ dwm-5.3.1/dwm.c 2008-12-08 20:33:16.000000000 +0100
@@ -23,6 +23,7 @@
*
* To understand everything else, start reading main().
*/
+#define _GNU_SOURCE
#include <errno.h>
#include <locale.h>
#include <stdarg.h>
@@ -238,6 +240,7 @@
static DC dc;
static Layout *lt[] = { NULL, NULL };
static Window root, barwin;
+static char **args;
/* configuration, allows nested code to access above variables */
#include "config.h"
@@ -1026,6 +1032,8 @@
void
quit(const Arg *arg) {
+ if(arg->i) /* restart dwm, if fails just fall through and exit */
+ execve(args[0], args, environ);
readin = running = False;
}
@@ -1733,6 +1741,7 @@
if(!(dpy = XOpenDisplay(0)))
die("dwm: cannot open display\n");
+ args = argv;
checkotherwm();
setup();
scan();