summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--config.def.h159
-rw-r--r--dwm.c31
3 files changed, 59 insertions, 133 deletions
diff --git a/README.md b/README.md
index 6d0a2aa..8ea03f9 100644
--- a/README.md
+++ b/README.md
@@ -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
diff --git a/config.def.h b/config.def.h
index 4820f55..d1aa5f6 100644
--- a/config.def.h
+++ b/config.def.h
@@ -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
diff --git a/dwm.c b/dwm.c
index a770804..a796b2d 100644
--- a/dwm.c
+++ b/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