Added RULE macro to replace rules setup making the default config less of an abomination and making it simpler to include new rules based patches

pull/32/head
bakkeby 4 years ago
parent 7ba6ea50bf
commit 6f20203975

@ -15,6 +15,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog:
2020-06-14 - Added RULE macro to replace rules setup making the default config less of an abomination and making it simpler to include new rules based patches
2020-06-11 - Added the pango patch
2020-06-10 - Added the staticstatus patch

@ -303,146 +303,41 @@ static const unsigned int drawtagmask = DRAWTAGGRID; /* | DRAWCLASSICTAGS to sho
static const int tagrows = 2;
#endif // TAGGRID_PATCH
/* There are two options when it comes to per-client rules:
* - a typical struct table or
* - using the RULE macro
*
* A traditional struct table looks like this:
* // class instance title tags mask isfloating monitor
* { "Gimp", NULL, NULL, 1 << 4, 0, -1 },
* { "Firefox", NULL, NULL, 1 << 7, 0, -1 },
*
* The RULE macro has the default values set for each field allowing you to only
* specify the values that are relevant for your rule, e.g.
*
* RULE(.class = "Gimp", .tags = 1 << 4)
* RULE(.class = "Firefox", .tags = 1 << 7)
*
* One benefit of using the RULE macro with a flexipatch build is that you do not have
* to worry about having to fiddle with rules when enabling or disabling patches. Field
* names that do not apply are simply ignored by the macro.
*
* Refer to the Rule struct definition for the list of available fields depending on
* the patches you enable.
*/
static const Rule rules[] = {
/* xprop(1):
* WM_CLASS(STRING) = instance, class
* WM_NAME(STRING) = title
* WM_WINDOW_ROLE(STRING) = role
*/
#if WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && CENTER_PATCH && ISPERMANENT_PATCH && SWALLOW_PATCH
/* class role instance title tags mask switchtag iscentered isfloating ispermanent isterminal noswallow monitor */
{ "Gimp", NULL, NULL, NULL, 0, 1, 0, 1, 0, 0, 0, -1 },
{ "Firefox", NULL, NULL, NULL, 1 << 8, 1, 0, 0, 0, 0, 0, -1 }
#elif WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && CENTER_PATCH && ISPERMANENT_PATCH && !SWALLOW_PATCH
/* class role instance title tags mask switchtag iscentered isfloating ispermanent monitor */
{ "Gimp", NULL, NULL, NULL, 0, 1, 0, 1, 0, -1 },
{ "Firefox", NULL, NULL, NULL, 1 << 8, 1, 0, 0, 0, -1 },
#elif WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && CENTER_PATCH && !ISPERMANENT_PATCH && SWALLOW_PATCH
/* class role instance title tags mask switchtag iscentered isfloating isterminal noswallow monitor */
{ "Gimp", NULL, NULL, NULL, 0, 1, 0, 1, 0, 0, -1 },
{ "Firefox", NULL, NULL, NULL, 1 << 8, 1, 0, 0, 0, 0, -1 },
#elif WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && CENTER_PATCH && !ISPERMANENT_PATCH && !SWALLOW_PATCH
/* class role instance title tags mask switchtag iscentered isfloating monitor */
{ "Gimp", NULL, NULL, NULL, 0, 1, 0, 1, -1 },
{ "Firefox", NULL, NULL, NULL, 1 << 8, 1, 0, 0, -1 },
#elif WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && CENTER_PATCH && ISPERMANENT_PATCH && SWALLOW_PATCH
/* class role instance title tags mask iscentered isfloating ispermanent isterminal noswallow monitor */
{ "Gimp", NULL, NULL, NULL, 0, 0, 1, 0, 0, 0, -1 },
{ "Firefox", NULL, NULL, NULL, 1 << 8, 0, 0, 0, 0, 0, -1 },
#elif WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && CENTER_PATCH && ISPERMANENT_PATCH && !SWALLOW_PATCH
/* class role instance title tags mask iscentered isfloating ispermanent monitor */
{ "Gimp", NULL, NULL, NULL, 0, 0, 1, 0, -1 },
{ "Firefox", NULL, NULL, NULL, 1 << 8, 0, 0, 0, -1 },
#elif WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && CENTER_PATCH && !ISPERMANENT_PATCH && SWALLOW_PATCH
/* class role instance title tags mask iscentered isfloating isterminal noswallow monitor */
{ "Gimp", NULL, NULL, NULL, 0, 0, 1, 0, 0, -1 },
{ "Firefox", NULL, NULL, NULL, 1 << 8, 0, 0, 0, 0, -1 },
#elif WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && CENTER_PATCH && !ISPERMANENT_PATCH && !SWALLOW_PATCH
/* class role instance title tags mask iscentered isfloating monitor */
{ "Gimp", NULL, NULL, NULL, 0, 0, 1, -1 },
{ "Firefox", NULL, NULL, NULL, 1 << 8, 0, 0, -1 },
#elif WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && !CENTER_PATCH && ISPERMANENT_PATCH && SWALLOW_PATCH
/* class role instance title tags mask switchtag isfloating ispermanent isterminal noswallow monitor */
{ "Gimp", NULL, NULL, NULL, 0, 1, 1, 0, 0, 0, -1 },
{ "Firefox", NULL, NULL, NULL, 1 << 8, 1, 0, 0, 0, 0, -1 },
#elif WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && !CENTER_PATCH && ISPERMANENT_PATCH && !SWALLOW_PATCH
/* class role instance title tags mask switchtag isfloating ispermanent monitor */
{ "Gimp", NULL, NULL, NULL, 0, 1, 1, 0, -1 },
{ "Firefox", NULL, NULL, NULL, 1 << 8, 1, 0, 0, -1 },
#elif WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && !CENTER_PATCH && !ISPERMANENT_PATCH && SWALLOW_PATCH
/* class role instance title tags mask switchtag isfloating isterminal noswallow monitor */
{ "Gimp", NULL, NULL, NULL, 0, 1, 1, 0, 0, -1 },
{ "Firefox", NULL, NULL, NULL, 1 << 8, 1, 0, 0, 0, -1 },
#elif WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && !CENTER_PATCH && !ISPERMANENT_PATCH && !SWALLOW_PATCH
/* class role instance title tags mask switchtag isfloating monitor */
{ "Gimp", NULL, NULL, NULL, 0, 1, 1, -1 },
{ "Firefox", NULL, NULL, NULL, 1 << 8, 1, 0, -1 },
#elif !WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && CENTER_PATCH && ISPERMANENT_PATCH && SWALLOW_PATCH
/* class instance title tags mask switchtag iscentered isfloating ispermanent isterminal noswallow monitor */
{ "Gimp", NULL, NULL, 0, 1, 0, 1, 0, 0, 0, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 1, 0, 0, 0, 0, 0, -1 },
#elif !WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && CENTER_PATCH && ISPERMANENT_PATCH && !SWALLOW_PATCH
/* class instance title tags mask switchtag iscentered isfloating ispermanent monitor */
{ "Gimp", NULL, NULL, 0, 1, 0, 1, 0, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 1, 0, 0, 0, -1 },
#elif !WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && CENTER_PATCH && !ISPERMANENT_PATCH && SWALLOW_PATCH
/* class instance title tags mask switchtag iscentered isfloating isterminal noswallow monitor */
{ "Gimp", NULL, NULL, 0, 1, 0, 1, 0, 0, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 1, 0, 0, 0, 0, -1 },
#elif !WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && CENTER_PATCH && !ISPERMANENT_PATCH && !SWALLOW_PATCH
/* class instance title tags mask switchtag iscentered isfloating monitor */
{ "Gimp", NULL, NULL, 0, 1, 0, 1, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 1, 0, 0, -1 },
#elif WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && !CENTER_PATCH && ISPERMANENT_PATCH && SWALLOW_PATCH
/* class role instance title tags mask isfloating ispermanent isterminal noswallow monitor */
{ "Gimp", NULL, NULL, NULL, 0, 1, 0, 0, 0, -1 },
{ "Firefox", NULL, NULL, NULL, 1 << 8, 0, 0, 0, 0, -1 },
#elif WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && !CENTER_PATCH && ISPERMANENT_PATCH && !SWALLOW_PATCH
/* class role instance title tags mask isfloating ispermanent monitor */
{ "Gimp", NULL, NULL, NULL, 0, 1, 0, -1 },
{ "Firefox", NULL, NULL, NULL, 1 << 8, 0, 0, -1 },
#elif WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && !CENTER_PATCH && !ISPERMANENT_PATCH && SWALLOW_PATCH
/* class role instance title tags mask isfloating isterminal noswallow monitor */
{ "Gimp", NULL, NULL, NULL, 0, 1, 0, 0, -1 },
{ "Firefox", NULL, NULL, NULL, 1 << 8, 0, 0, 0, -1 },
#elif WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && !CENTER_PATCH && !ISPERMANENT_PATCH && !SWALLOW_PATCH
/* class role instance title tags mask isfloating monitor */
{ "Gimp", NULL, NULL, NULL, 0, 1, -1 },
{ "Firefox", NULL, NULL, NULL, 1 << 8, 0, -1 },
#elif !WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && !CENTER_PATCH && ISPERMANENT_PATCH && SWALLOW_PATCH
/* class instance title tags mask switchtag isfloating ispermanent isterminal noswallow monitor */
{ "Gimp", NULL, NULL, 0, 1, 1, 0, 0, 0, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 1, 0, 0, 0, 0, -1 },
#elif !WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && !CENTER_PATCH && ISPERMANENT_PATCH && !SWALLOW_PATCH
/* class instance title tags mask switchtag isfloating ispermanent monitor */
{ "Gimp", NULL, NULL, 0, 1, 1, 0, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 1, 0, 0, -1 },
#elif !WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && !CENTER_PATCH && !ISPERMANENT_PATCH && SWALLOW_PATCH
/* class instance title tags mask switchtag isfloating isterminal noswallow monitor */
{ "Gimp", NULL, NULL, 0, 1, 1, 0, 0, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 1, 0, 0, 0, -1 },
#elif !WINDOWROLERULE_PATCH && SWITCHTAG_PATCH && !CENTER_PATCH && !ISPERMANENT_PATCH && !SWALLOW_PATCH
/* class instance title tags mask switchtag isfloating monitor */
{ "Gimp", NULL, NULL, 0, 1, 1, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 1, 0, -1 },
#elif !WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && CENTER_PATCH && ISPERMANENT_PATCH && SWALLOW_PATCH
/* class instance title tags mask iscentered isfloating ispermanent isterminal noswallow monitor */
{ "Gimp", NULL, NULL, 0, 0, 1, 0, 0, 0, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 0, 0, 0, 0, 0, -1 },
#elif !WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && CENTER_PATCH && ISPERMANENT_PATCH && !SWALLOW_PATCH
/* class instance title tags mask iscentered isfloating ispermanent monitor */
{ "Gimp", NULL, NULL, 0, 0, 1, 0, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 0, 0, 0, -1 },
#elif !WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && CENTER_PATCH && !ISPERMANENT_PATCH && SWALLOW_PATCH
/* class instance title tags mask iscentered isfloating isterminal noswallow monitor */
{ "Gimp", NULL, NULL, 0, 0, 1, 0, 0, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 0, 0, 0, 0, -1 },
#elif !WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && CENTER_PATCH && !ISPERMANENT_PATCH && !SWALLOW_PATCH
/* class instance title tags mask iscentered isfloating monitor */
{ "Gimp", NULL, NULL, 0, 0, 1, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 0, 0, -1 },
#elif !WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && !CENTER_PATCH && ISPERMANENT_PATCH && SWALLOW_PATCH
/* class instance title tags mask isfloating ispermanent isterminal noswallow monitor */
{ "Gimp", NULL, NULL, 0, 1, 0, 0, 0, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 0, 0, 0, 0, -1 },
#elif !WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && !CENTER_PATCH && ISPERMANENT_PATCH && !SWALLOW_PATCH
/* class instance title tags mask isfloating ispermanent monitor */
{ "Gimp", NULL, NULL, 0, 1, 0, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 0, 0, -1 },
#elif !WINDOWROLERULE_PATCH && !SWITCHTAG_PATCH && !CENTER_PATCH && !ISPERMANENT_PATCH && SWALLOW_PATCH
/* class instance title tags mask isfloating isterminal noswallow monitor */
{ "Gimp", NULL, NULL, 0, 1, 0, 0, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 0, 0, 0, -1 },
#else
/* class instance title tags mask isfloating monitor */
{ "Gimp", NULL, NULL, 0, 1, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 0, -1 },
RULE(.class = "Gimp", .tags = 1 << 4)
RULE(.class = "Firefox", .tags = 1 << 7)
#if SCRATCHPADS_PATCH
{ NULL, "spterm", NULL, SPTAG(0), 1, -1 },
{ NULL, "spfm", NULL, SPTAG(1), 1, -1 },
{ NULL, "keepassxc",NULL, SPTAG(2), 0, -1 },
RULE(.instance = "spterm", .tags = SPTAG(0), .isfloating = 1)
RULE(.instance = "spfm", .tags = SPTAG(1), .isfloating = 1)
RULE(.instance = "keepassxc", .tags = SPTAG(2))
#endif // SCRATCHPADS_PATCH
#endif
};
#if MONITOR_RULES_PATCH

31
dwm.c

@ -323,6 +323,33 @@ typedef struct {
int monitor;
} Rule;
#define R_WINDOWROLERULE_(enabled) R_WINDOWROLERULE_##enabled
#define R_WINDOWROLERULE(enabled) R_WINDOWROLERULE_(enabled)
#define R_WINDOWROLERULE_0
#define R_WINDOWROLERULE_1 .role = NULL,
#define R_SWITCHTAG_(enabled) R_SWITCHTAG_##enabled
#define R_SWITCHTAG(enabled) R_SWITCHTAG_(enabled)
#define R_SWITCHTAG_0
#define R_SWITCHTAG_1 .switchtag = 0,
#define R_CENTER_(enabled) R_CENTER_##enabled
#define R_CENTER(enabled) R_CENTER_(enabled)
#define R_CENTER_0
#define R_CENTER_1 .iscentered = 0,
#define R_ISPERMANENT_(enabled) R_ISPERMANENT_##enabled
#define R_ISPERMANENT(enabled) R_ISPERMANENT_(enabled)
#define R_ISPERMANENT_0
#define R_ISPERMANENT_1 .ispermanent = 0,
#define R_SWALLOW_(enabled) R_SWALLOW_##enabled
#define R_SWALLOW(enabled) R_SWALLOW_(enabled)
#define R_SWALLOW_0
#define R_SWALLOW_1 .isterminal = 0, .noswallow = 1,
#define RULE(...) { .class = NULL, R_WINDOWROLERULE(WINDOWROLERULE_PATCH) .instance = NULL, .title = NULL, .tags = 0, R_SWITCHTAG(SWITCHTAG_PATCH) R_CENTER(CENTER_PATCH) .isfloating = 0, R_ISPERMANENT(ISPERMANENT_PATCH) R_SWALLOW(SWALLOW_PATCH) .monitor = -1 },
#if MONITOR_RULES_PATCH
typedef struct {
int monitor;
@ -4276,8 +4303,10 @@ main(int argc, char *argv[])
die("dwm-"VERSION);
else if (!strcmp("-h", argv[i]) || !strcmp("--help", argv[i]))
die(help());
#if !PANGO_PATCH
else if (!strcmp("-fn", argv[i])) /* font set */
#if PANGO_PATCH
strcpy(font, argv[++i]);
#else
fonts[0] = argv[++i];
#endif // PANGO_PATCH
#if !VTCOLORS_PATCH

Loading…
Cancel
Save