Added layout menu popup which presents available layouts after right-clicking the...
[dwm] / dwm.c
diff --git a/dwm.c b/dwm.c
index 14fe6cc..a94b759 100644 (file)
--- a/dwm.c
+++ b/dwm.c
@@ -178,6 +178,7 @@ static void grabkeys(void);
 static void incnmaster(const Arg *arg);
 static void keypress(XEvent *e);
 static void killclient(const Arg *arg);
 static void incnmaster(const Arg *arg);
 static void keypress(XEvent *e);
 static void killclient(const Arg *arg);
+static void layoutmenu(const Arg *arg);
 static void manage(Window w, XWindowAttributes *wa);
 static void mappingnotify(XEvent *e);
 static void maprequest(XEvent *e);
 static void manage(Window w, XWindowAttributes *wa);
 static void mappingnotify(XEvent *e);
 static void maprequest(XEvent *e);
@@ -1068,6 +1069,24 @@ killclient(const Arg *arg)
        }
 }
 
        }
 }
 
+void
+layoutmenu(const Arg *arg) {
+       FILE *p;
+       char c[3], *s;
+       int i;
+
+       if (!(p = popen(layoutmenu_cmd, "r")))
+                return;
+       s = fgets(c, sizeof(c), p);
+       pclose(p);
+
+       if (!s || *s == '\0' || c[0] == '\0')
+                return;
+
+       i = atoi(c);
+       setlayout(&((Arg) { .v = &layouts[i] }));
+}
+
 void
 manage(Window w, XWindowAttributes *wa)
 {
 void
 manage(Window w, XWindowAttributes *wa)
 {