Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

renamed scratchpads patch #350

Open
kronikpillow opened this issue Apr 18, 2023 · 2 comments
Open

renamed scratchpads patch #350

kronikpillow opened this issue Apr 18, 2023 · 2 comments

Comments

@kronikpillow
Copy link

kronikpillow commented Apr 18, 2023

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
Copy link
Owner

bakkeby commented Apr 18, 2023

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:

  • the scratchpad command is passed as an argument and the first character of the command is used as the scratch key
  • it will loop through all clients managed by the window manager looking for clients that has the particular scratch key of s
  • if any are found then:
    • if the client or clients are not shown then they will be brought into view
    • otherwise if they are shown then they will be toggled out of view
  • otherwise if there are no clients with that scratch key found then the command is executed to spawn the program
  • in which case it is expected that there is a client rule matching that program setting the scratch key to s so that the client can be found the next time the user hits that key combination to toggle the scratchpad

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants