Created
February 10, 2023 16:13
-
-
Save bpsuntrup/8f9946f4e6ed7c5dbe1329095dc78cc2 to your computer and use it in GitHub Desktop.
patch to reload dwm in-flight
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/dwm.c b/dwm.c | |
index e5efb6a..a033028 100644 | |
--- a/dwm.c | |
+++ b/dwm.c | |
@@ -189,6 +189,7 @@ static void pop(Client *c); | |
static void propertynotify(XEvent *e); | |
static void quit(const Arg *arg); | |
static Monitor *recttomon(int x, int y, int w, int h); | |
+static void reload(const Arg *arg); | |
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); | |
static void resizemouse(const Arg *arg); | |
@@ -1266,6 +1267,13 @@ recttomon(int x, int y, int w, int h) | |
return r; | |
} | |
+void | |
+reload(const Arg *arg) | |
+{ | |
+ char *argv[] = { "dwm", NULL }; | |
+ execvp( "dwm", argv); | |
+} | |
+ | |
void | |
resize(Client *c, int x, int y, int w, int h, int interact) | |
{ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(Probably should have called this "restart" rather than "reload".)
This just restarts dwm in place. execvp works the same way calling "dwm" from the command line works, so if you have multiple binaries installed, it will load the first one it finds in $PATH. The Arch Wiki suggests making a script that reloads dwm for you when you quit,
...but I dislike this for a few reasons. I prefer to run
make clean install
and then just restart dwm in place with a key binding:{ MODKEY, XK_r, reload, {0} },
This particular patch belongs to me (Benjamin Suntrup) and is licensed under the GPLv3. Contact me if you have trouble figuring out what that means :)