all repos — openbox @ db1c0809ef18a40fe4e1974a0cfb6bfdf080eccb

openbox fork - make it a bit more like ryudo

Let the If action match window titles with GRegex
Mikael Magnusson mikachu@gmail.com
commit

db1c0809ef18a40fe4e1974a0cfb6bfdf080eccb

parent

5a1da743ca6f8889e9c58aca84a3481c59c6a246

1 files changed, 21 insertions(+), 3 deletions(-)

jump to
M openbox/actions/if.copenbox/actions/if.c

@@ -30,6 +30,8 @@ gboolean desktop_other;

guint desktop_number; guint screendesktop_number; GPatternSpec *matchtitle; + GRegex *regextitle; + gchar *plaintitle; GSList *thenacts; GSList *elseacts; } Options;

@@ -91,9 +93,17 @@ if ((n = obt_xml_find_node(node, "activedesktop"))) {

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, "plain")) { + o->plaintitle = g_strdup(s); + } g_free(s); } }

@@ -136,6 +146,10 @@ o->elseacts = g_slist_delete_link(o->elseacts, o->elseacts);

} if (o->matchtitle) g_pattern_spec_free(o->matchtitle); + if (o->regextitle) + g_regex_unref(o->regextitle); + if (o->plaintitle) + g_free(o->plaintitle); g_slice_free(Options, o); }

@@ -174,7 +188,11 @@ (!o->desktop_number || ((c->desktop == o->desktop_number - 1) ||

(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->plaintitle || + (!strcmp(o->plaintitle, c->original_title)))) { acts = o->thenacts; }