From 11b1ff4691ff3e0f8346e7431fa3f90cc846fc5d Mon Sep 17 00:00:00 2001 From: Filip Wandzio Date: Sun, 28 Dec 2025 02:37:34 +0100 Subject: Add hot restart patch --- README.md | 38 ++++++++++++++++---------------------- src/config/config.def.h | 1 + src/config/config.h | 1 + src/core/dwm.c | 6 ++++++ src/core/dwm.h | 1 + 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 95d4fd0..15a362f 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,4 @@ -dwm - dynamic window manager -============================ -dwm is an extremely fast, small, and dynamic window manager for X. - - -Requirements ------------- -In order to build dwm you need the Xlib header files. - - -Installation +## Installation ------------ Edit config.mk to match your local setup (dwm is installed into the /usr/local namespace by default). @@ -16,33 +6,37 @@ the /usr/local namespace by default). Afterwards enter the following command to build and install dwm (if necessary as root): +```bash make clean install +``` - -Running dwm ------------ +## Running dwm Add the following line to your .xinitrc to start dwm using startx: - +```bash exec dwm +``` In order to connect dwm to a specific display, make sure that the DISPLAY environment variable is set correctly, e.g.: +```bash DISPLAY=foo.bar:1 exec dwm - -(This will start dwm on display :1 of the host foo.bar.) - +``` In order to display status info in the bar, you can do something like this in your .xinitrc: - while xsetroot -name "`date` `uptime | sed 's/.*,//'`" +```bash + while xsetroot -name "`date` `uptime | sed 's/.*,//'`" do sleep 1 done & exec dwm +``` - -Configuration -------------- +## Configuration The configuration of dwm is done by creating a custom config.h and (re)compiling the source code. + +## Additional resources + +Restart patch pulled from (gist.github.org/bpsuntrup)[bpsuntrup's gist] diff --git a/src/config/config.def.h b/src/config/config.def.h index 3135869..9c372da 100644 --- a/src/config/config.def.h +++ b/src/config/config.def.h @@ -87,6 +87,7 @@ static const Key keys[] = { {MODKEY | ShiftMask, XK_s, spawn, {.v = screenshotcmd}}, {MODKEY, XK_b, togglebar, {0}}, {MODKEY, XK_q, killclient, {0}}, + {MODKEY, XK_r, restart, {0}}, {MODKEY, XK_f, togglefullscr, {0}}, {MODKEY, XK_l, setlayout, {0}}, {MODKEY | ShiftMask, XK_space, togglefloating, {0}}, diff --git a/src/config/config.h b/src/config/config.h index 3135869..9c372da 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -87,6 +87,7 @@ static const Key keys[] = { {MODKEY | ShiftMask, XK_s, spawn, {.v = screenshotcmd}}, {MODKEY, XK_b, togglebar, {0}}, {MODKEY, XK_q, killclient, {0}}, + {MODKEY, XK_r, restart, {0}}, {MODKEY, XK_f, togglefullscr, {0}}, {MODKEY, XK_l, setlayout, {0}}, {MODKEY | ShiftMask, XK_space, togglefloating, {0}}, diff --git a/src/core/dwm.c b/src/core/dwm.c index e16bc2f..cd7fdb0 100644 --- a/src/core/dwm.c +++ b/src/core/dwm.c @@ -1436,6 +1436,12 @@ void restack(Monitor *m) ; } +void restart(const Arg *arg) +{ + char *argv[] = {"dwm", NULL}; + execvp("dwm", argv); +} + void run(void) { XEvent ev; diff --git a/src/core/dwm.h b/src/core/dwm.h index 090448a..273645a 100644 --- a/src/core/dwm.h +++ b/src/core/dwm.h @@ -176,6 +176,7 @@ static void resizeclient(Client *c, int x, int y, int w, int h); static void resizemouse(const Arg *arg); static void resizerequest(XEvent *e); static void restack(Monitor *m); +static void restart(const Arg *arg); static void run(void); static void scan(void); static int sendevent(Window w, Atom proto, int m, long d0, long d1, long d2, -- cgit v1.2.3