sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-scratchtagwins-6.3.diff (4152B)


      1 diff --git a/config.def.h b/config.def.h
      2 index a2ac963..ae54a10 100644
      3 --- a/config.def.h
      4 +++ b/config.def.h
      5 @@ -21,6 +21,8 @@ static const char *colors[][3]      = {
      6  /* tagging */
      7  static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
      8  
      9 +#include "scratchtagwins.c"
     10 +
     11  static const Rule rules[] = {
     12  	/* xprop(1):
     13  	 *	WM_CLASS(STRING) = instance, class
     14 @@ -29,6 +31,15 @@ static const Rule rules[] = {
     15  	/* class      instance    title       tags mask     isfloating   monitor */
     16  	{ "Gimp",     NULL,       NULL,       0,            1,           -1 },
     17  	{ "Firefox",  NULL,       NULL,       1 << 8,       0,           -1 },
     18 +	SCRATCHTAGWIN_RULE (scratchtagwin1, 1),
     19 +	SCRATCHTAGWIN_RULE (scratchtagwin2, 2),
     20 +	SCRATCHTAGWIN_RULE (scratchtagwin3, 3),
     21 +	SCRATCHTAGWIN_RULE (scratchtagwin4, 4),
     22 +	SCRATCHTAGWIN_RULE (scratchtagwin5, 5),
     23 +	SCRATCHTAGWIN_RULE (scratchtagwin6, 6),
     24 +	SCRATCHTAGWIN_RULE (scratchtagwin7, 7),
     25 +	SCRATCHTAGWIN_RULE (scratchtagwin8, 8),
     26 +	SCRATCHTAGWIN_RULE (scratchtagwin9, 9),
     27  };
     28  
     29  /* layout(s) */
     30 @@ -60,10 +71,31 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn()
     31  static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
     32  static const char *termcmd[]  = { "st", NULL };
     33  
     34 +SCRATCHTAGWIN (scratchtagwin1, 1);
     35 +SCRATCHTAGWIN (scratchtagwin2, 2);
     36 +SCRATCHTAGWIN (scratchtagwin3, 3);
     37 +SCRATCHTAGWIN (scratchtagwin4, 4);
     38 +SCRATCHTAGWIN (scratchtagwin5, 5);
     39 +SCRATCHTAGWIN (scratchtagwin6, 6);
     40 +SCRATCHTAGWIN (scratchtagwin7, 7);
     41 +SCRATCHTAGWIN (scratchtagwin8, 8);
     42 +SCRATCHTAGWIN (scratchtagwin9, 9);
     43 +
     44  static Key keys[] = {
     45  	/* modifier                     key        function        argument */
     46  	{ MODKEY,                       XK_p,      spawn,          {.v = dmenucmd } },
     47  	{ MODKEY|ShiftMask,             XK_Return, spawn,          {.v = termcmd } },
     48 +	SCRATCHTAGWIN_KEY (scratchtagwin1, 1)
     49 +	SCRATCHTAGWIN_KEY (scratchtagwin2, 2)
     50 +	SCRATCHTAGWIN_KEY (scratchtagwin3, 3)
     51 +	SCRATCHTAGWIN_KEY (scratchtagwin4, 4)
     52 +	SCRATCHTAGWIN_KEY (scratchtagwin5, 5)
     53 +	SCRATCHTAGWIN_KEY (scratchtagwin6, 6)
     54 +	SCRATCHTAGWIN_KEY (scratchtagwin7, 7)
     55 +	SCRATCHTAGWIN_KEY (scratchtagwin8, 8)
     56 +	SCRATCHTAGWIN_KEY (scratchtagwin9, 9)
     57 +	{ MODKEY|AltMask|ShiftMask,     XK_0,  makescratchtagwin,  {.i = 0} },
     58 +	{ MODKEY|AltMask|ShiftMask,     XK_s,  makescratchtagwin,  {.i = 's'} },
     59  	{ MODKEY,                       XK_b,      togglebar,      {0} },
     60  	{ MODKEY,                       XK_j,      focusstack,     {.i = +1 } },
     61  	{ MODKEY,                       XK_k,      focusstack,     {.i = -1 } },
     62 diff --git a/scratchtagwins.c b/scratchtagwins.c
     63 new file mode 100644
     64 index 0000000..bf43b17
     65 --- /dev/null
     66 +++ b/scratchtagwins.c
     67 @@ -0,0 +1,53 @@
     68 +#include <stdio.h>
     69 +#include <stdlib.h>
     70 +#include <string.h>
     71 +
     72 +#include <X11/XF86keysym.h>
     73 +
     74 +# define SCRATCHTAGWIN(name, id)								\
     75 +	static const char * name [] = { # id,						\
     76 +		"tabbed",												\
     77 +			"-p", "s+1",										\
     78 +			"-n", # name,										\
     79 +			"-g", "1195x672",									\
     80 +			"-c", "st", "-w",									\
     81 +		NULL													\
     82 +	}															\
     83 +
     84 +# define SCRATCHTAGWIN_RULE(name, id)																	\
     85 +	{ NULL,       # name, NULL,       0,            1,           1,           -1,      '0' + id }		\
     86 +
     87 +# define SCRATCHTAGWIN_KEY(name, id)														\
     88 +	{ MODKEY|AltMask,          XK_ ## id,      togglescratch,  {.v = name } },				\
     89 +	{ MODKEY|AltMask|ShiftMask,XK_ ## id,      makescratchtagwin,{.i = '0' + id } },		\
     90 +
     91 +static void makescratchtagwin (const Arg * arg)
     92 +{
     93 +	if (selmon -> sel)
     94 +	{
     95 +		if (arg -> i != 0)
     96 +		{
     97 +			_Bool exists = 0;
     98 +
     99 +			for (Client * c = selmon -> clients; c; c = c -> next)
    100 +				if (c -> scratchkey == arg -> i)
    101 +				{
    102 +					exists = 1;
    103 +					break;
    104 +				}
    105 +
    106 +			if (exists) return;
    107 +		}
    108 +
    109 +		selmon -> sel -> scratchkey = arg -> i;
    110 +		if (arg -> i != 0)
    111 +		{
    112 +			selmon -> sel -> tags = 0,
    113 +			selmon -> sel -> isfloating = 1;
    114 +		}
    115 +		else
    116 +			selmon -> sel -> tags = selmon -> tagset [selmon -> seltags];
    117 +		focus (selmon -> sel);
    118 +		arrange (selmon);
    119 +	}
    120 +}