[hackers] [dwm][PATCH] Remove dmenumon variable

From: Stein <bakkeby_AT_gmail.com>
Date: Fri, 26 Aug 2022 14:48:46 +0200

Reasoning: Since 2011 dmenu has been capable of working out which
monitor currently has focus in a Xinerama setup, making the use
of the -m flag more or less redundant.

This is easily demonstrated by using dmenu in any other window

There used to be a nodmenu patch that provided these changes:

but this was removed on the basis that it was very easy to work
out and apply manually if needed.

The proposal here is to remove this dependency from dwm. The
mechanism of the dmenumon variable could be provided via a patch
if need be.

The edge case scenario that dmenu does not handle on its own, and
the effect of removing this mechanism, is that if the user trigger
focusmon via keybindings to change focus to another monitor that
has no clients, then dmenu will open on the monitor containing the
window with input focus (or the monitor with the mouse cursor if
no windows have input focus).

If this edge case is important to cover then this can be addressed
by setting input focus to selmon->barwin in the focus function if
there is no client to give focus to (rather than giving focus back
to the root window).
 config.def.h | 3 +--
 dwm.c        | 2 --
 2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/config.def.h b/config.def.h
index 9efa774..061ad66 100644
--- a/config.def.h
+++ b/config.def.h
_AT_@ -56,8 +56,7 @@ static const Layout layouts[] = {
 #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
 /* commands */
-static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
-static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
+static const char *dmenucmd[] = { "dmenu_run", "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
 static const char *termcmd[]  = { "st", NULL };
 static const Key keys[] = {
diff --git a/dwm.c b/dwm.c
index 253aba7..e5efb6a 100644
--- a/dwm.c
+++ b/dwm.c
_AT_@ -1639,8 +1639,6 @@ sigchld(int unused)
 spawn(const Arg *arg)
-	if (arg->v == dmenucmd)
-		dmenumon[0] = '0' + selmon->num;
 	if (fork() == 0) {
 		if (dpy)
Received on Fri Aug 26 2022 - 14:48:46 CEST

This archive was generated by hypermail 2.3.0 : Fri Aug 26 2022 - 15:00:38 CEST