gboolean desktop_other;
guint desktop_number;
guint screendesktop_number;
+ guint client_monitor;
GPatternSpec *matchtitle;
+ GRegex *regextitle;
+ gchar *exacttitle;
GSList *thenacts;
GSList *elseacts;
} Options;
actions_register("If", setup_func, free_func, run_func);
}
-static inline set_bool(xmlNodePtr node,
- const char *name,
- gboolean *on,
- gboolean *off)
+static inline void set_bool(xmlNodePtr node,
+ const char *name,
+ gboolean *on,
+ gboolean *off)
{
xmlNodePtr n;
o->screendesktop_number = obt_xml_node_int(n);
}
if ((n = obt_xml_find_node(node, "title"))) {
- gchar *s;
+ gchar *s, *type = NULL;
if ((s = obt_xml_node_string(n))) {
- o->matchtitle = g_pattern_spec_new(s);
+ if (!obt_xml_attr_string(n, "type", &type) ||
+ !g_ascii_strcasecmp(type, "pattern"))
+ {
+ o->matchtitle = g_pattern_spec_new(s);
+ } else if (type && !g_ascii_strcasecmp(type, "regex")) {
+ o->regextitle = g_regex_new(s, 0, 0, NULL);
+ } else if (type && !g_ascii_strcasecmp(type, "exact")) {
+ o->exacttitle = g_strdup(s);
+ }
g_free(s);
}
}
+ if ((n = obt_xml_find_node(node, "monitor"))) {
+ o->client_monitor = obt_xml_node_int(n);
+ }
if ((n = obt_xml_find_node(node, "then"))) {
xmlNodePtr m;
}
if (o->matchtitle)
g_pattern_spec_free(o->matchtitle);
+ if (o->regextitle)
+ g_regex_unref(o->regextitle);
+ if (o->exacttitle)
+ g_free(o->exacttitle);
g_slice_free(Options, o);
}
(c->desktop == DESKTOP_ALL))) &&
(!o->screendesktop_number || screen_desktop == o->screendesktop_number - 1) &&
(!o->matchtitle ||
- (g_pattern_match_string(o->matchtitle, c->original_title))))
+ (g_pattern_match_string(o->matchtitle, c->original_title))) &&
+ (!o->regextitle ||
+ (g_regex_match(o->regextitle, c->original_title, 0, NULL))) &&
+ (!o->exacttitle ||
+ (!strcmp(o->exacttitle, c->original_title))) &&
+ (!o->client_monitor ||
+ (o->client_monitor == client_monitor(c) + 1)))
{
acts = o->thenacts;
}