Closed gcoelho05 closed 2 years ago
The way the togglescratch
function works is that it will search through all clients looking for a given scratch key. If such a client is found then it will be brought into view, but if there is no such client then it will execute the given command to spawn the program.
At some point later in time a window will come up asking to be mapped. There is no direct correlation between starting a program and a window popping up, so this process is asynchronous - which is the very reason why we need to have this dance around scratch keys and client rules. The client rules are there to identify the window as to associate it with the corresponding scratch key - so that the next time you trigger togglescratch
it will find said client and bring that into view rather than spawning a new program.
Your config is all fine, the only problem is that you are using the same scratch key of s
for all of them.
My personal recommendation is to use the same character as for the keybinding, i.e. m
, p
, y
, w
and t
in this case. Likewise with the command variable names I would recommend using similar references, e.g.
{ MODKEY|ControlMask, XK_m, togglescratch, {.v = spcmd_m } },
{ MODKEY|ControlMask, XK_p, togglescratch, {.v = spcmd_p } },
{ MODKEY|ControlMask, XK_y, togglescratch, {.v = spcmd_y } },
{ MODKEY|ControlMask, XK_w, togglescratch, {.v = spcmd_w } },
{ MODKEY|ControlMask, XK_t, togglescratch, {.v = spcmd_t } },
This just because it makes it a bit more generic and you don't need to touch it again should you want to replace the scratchpad on MOD+Ctrl+y
- you just need to change the command inside spcmd_y
and the rule to match.
Thank you for your help and detailed explanation. I did not realise I had to change the scratch key. I also followed your rule name suggestion, making it generic is indeed a good idea.
In my config.h, I have the following:
I might be doing something wrong, but when I press, say, mod+control+m, to toggle the mutt scratchpad, it'll open just fine. Though, if the mutt scratchpad has already been opened, pressing, say, mod+control+p, will toggle mutt again, instead of pulsemixer.
EDIT: I am using this patch from dwm-flexipatch.