summary refs log tree commit diff
path: root/search.c
diff options
context:
space:
mode:
authorokan <okan>2017-12-29 20:03:46 +0000
committerokan <okan>2017-12-29 20:03:46 +0000
commit6e7dbf5bb71d56bb3443f57cb6b8707a291fe0d2 (patch)
tree6e842f14936d6a213a69c49587ce62cb92512925 /search.c
parent43db5b55eaae67515ae926c0d195c1ef6aa4b607 (diff)
downloadcwm-6e7dbf5bb71d56bb3443f57cb6b8707a291fe0d2.tar.gz
cwm-6e7dbf5bb71d56bb3443f57cb6b8707a291fe0d2.tar.xz
cwm-6e7dbf5bb71d56bb3443f57cb6b8707a291fe0d2.zip
Convert menu-exec-wm from an abritrary exec menu, into a config-based menu from
which one may configure (wm <name> <path_and_args>) (and choose) specific
window managers to replace the running one. 'wm cwm cwm' is included by
default.

No objections and seems sensible to sthen.
Diffstat (limited to 'search.c')
-rw-r--r--search.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/search.c b/search.c
index 59aa841..7d3bd21 100644
--- a/search.c
+++ b/search.c
@@ -228,6 +228,21 @@ search_match_text(struct menu_q *menuq, struct menu_q *resultq, char *search)
 }
 
 void
+search_match_wm(struct menu_q *menuq, struct menu_q *resultq, char *search)
+{
+	struct menu		*mi;
+	struct cmd_ctx		*wm;
+
+	TAILQ_INIT(resultq);
+	TAILQ_FOREACH(mi, menuq, entry) {
+		wm = (struct cmd_ctx *)mi->ctx;
+		if ((match_substr(search, wm->name, 0)) ||
+		    (match_substr(search, wm->path, 0)))
+			TAILQ_INSERT_TAIL(resultq, mi, resultentry);
+	}
+}
+
+void
 search_print_client(struct menu *mi, int listing)
 {
 	struct client_ctx	*cc = (struct client_ctx *)mi->ctx;
@@ -266,3 +281,12 @@ search_print_text(struct menu *mi, int listing)
 {
 	(void)snprintf(mi->print, sizeof(mi->print), "%s", mi->text);
 }
+
+void
+search_print_wm(struct menu *mi, int listing)
+{
+	struct cmd_ctx		*wm = (struct cmd_ctx *)mi->ctx;
+
+	(void)snprintf(mi->print, sizeof(mi->print), "%s [%s]",
+	    wm->name, wm->path);
+}