bakkeby / dwm-flexipatch

A dwm build with preprocessor directives to decide which patches to include during build time
MIT License
1.18k stars 238 forks source link

renamed scratchpads patch #350

Open kronikpillow opened 1 year ago

kronikpillow commented 1 year ago

i recently switched to the renamed scratchpads patch for multi monitor support ... and am now confused as to how this patch is configured ...

before when i used namedscratchpads patch i did

typedef struct {
    const char *name;
    const void *cmd;
} Sp;
const char *spcmd1[] = {TERMINAL, "-n", "spterm", "-g", "120x34", NULL };
const char *spcmd2[] = {TERMINAL, "-n", "spcalc", "-f", "monospace:size=16", "-g", "50x20", "-e", "bc", "-lq", NULL };
static Sp scratchpads[] = {
    /* name          cmd  */
    {"spterm",      spcmd1},
    {"spcalc",      spcmd2},
};

and then

    { MODKEY,                       XK_s,          togglescratch,          {.ui = 0} },
    { MODKEY,                       XK_apostrophe, togglescratch,          {.ui = 1} },

but now im confused about the "key" part of the

static const char *scratchpadcmd[] = {"s", "st", "-n", "spterm", NULL};

because of

    { MODKEY,                       XK_grave,      togglescratch,          {.v = scratchpadcmd } },
    { MODKEY|ControlMask,           XK_grave,      setscratch,             {.v = scratchpadcmd } },
    { MODKEY|ShiftMask,             XK_grave,      removescratch,          {.v = scratchpadcmd } },

and because of

    RULE(.instance = "spterm", .scratchkey = 's', .isfloating = 1)

the .scratchkey is set to s, the termcmd is set to s ... yet hitting MOD+Grave ... gives me spterm? so what is actually .scratchkey? and how would i define a second permanent scratchpad for spcalc like i did in the previous patch?

bakkeby commented 1 year ago

I believe that you are confusing the scratchpads patch with the namedscratchpads patch, the old configuration you refer to is for the former.

The way it worked in the scratchpads patch is that there were additional "hidden" tags and the toggling of these were based on the given index in the scratchpads array.

In the named scratchpads patch there is the concept of a scratch key which essentially is a single character that uniquely identifies a given scratchpad. In the example configuration above the character s defines a specific scratchpad.

Let's say that you hit MOD+s to toggle the scratchpad.

What happens is that:

To answer your question you just define different commands that have a unique character identifying the given scratchpad. In general I recommend using the same character as the intended keyboard shortcut, e.g. if using MOD+y to toggle the scratchpad then I would use y as the scratch key for the command as well as the client rule.

There is some more information about this implementation of the named scratchpads that can be found here:

kronikpillow commented 1 year ago

ok ... well that explains the confusion, cuz in the default config provided by flexipatch the scratchkey is set to s, while it's bound to grave ... hitting MOD+s doesn't do anything