diff options
| -rw-r--r-- | config.h | 8 | ||||
| -rw-r--r-- | dwm.c | 2 | ||||
| -rw-r--r-- | quicksearch.c | 127 |
3 files changed, 6 insertions, 131 deletions
@@ -19,6 +19,8 @@ static const char *colors[][4] = { }; static const char *const autostart[] = { +/* program arguments options null terminator */ +// "st", "-c stfloat -e", "htop", NULL, NULL }; @@ -72,7 +74,7 @@ static const Layout layouts[] = { /* commands */ static const char *termcmd[] = { TERMINAL, NULL }; -#include "quicksearch.c" +#include "search.c" #include "togglemouse.c" #include <X11/XF86keysym.h> static const Key keys[] = { @@ -130,8 +132,8 @@ static const Key keys[] = { { MODKEY, XK_Print, spawn, SHCMD("maimpick") }, { MODKEY, XK_c, spawn, SHCMD("pgrep xcompmgr && pkill -9 xcompmgr || xcompmgr &") }, - { MODKEY, XK_p, quicksearch, {.i = 0} }, - { MODKEY|ShiftMask, XK_p, quicksearch, {.i = 1} }, + { MODKEY, XK_p, search, {.i = 0} }, + { MODKEY|ShiftMask, XK_p, search, {.i = 1} }, { MODKEY, XK_b, togglemouse, {0} }, }; @@ -235,7 +235,7 @@ static int xerrordummy(Display *dpy, XErrorEvent *ee); static int xerrorstart(Display *dpy, XErrorEvent *ee); static void zoom(const Arg *arg); static void togglemouse(const Arg *arg); -static void quicksearch(const Arg *arg); +static void search(const Arg *arg); static void autostart_exec(void); static pid_t getparentprocess(pid_t p); diff --git a/quicksearch.c b/quicksearch.c deleted file mode 100644 index bd9b7d1..0000000 --- a/quicksearch.c +++ /dev/null @@ -1,127 +0,0 @@ -void -quicksearch(const Arg *arg) -{ - Client *c; - Monitor *m; - char *names = NULL; - size_t names_size = 0; - size_t names_len = 0; - int client_count = 0; - Client **clients = NULL; - size_t clients_size = 0; - int mode = arg->i; - - for (m = mons; m; m = m->next) { - for (c = m->clients; c; c = c->next) { - if (!ISVISIBLE(c)) { - client_count++; - - char tag_str[64] = "["; - int tag_len = 1; - int first = 1; - for (int i = 0; i < LENGTH(tags); i++) { - if (c->tags & (1 << i)) { - if (!first) tag_len += snprintf(tag_str + tag_len, sizeof(tag_str) - tag_len, ","); - tag_len += snprintf(tag_str + tag_len, sizeof(tag_str) - tag_len, "%d", i + 1); - first = 0; - } - } - tag_len += snprintf(tag_str + tag_len, sizeof(tag_str) - tag_len, "] "); - - size_t name_len = strlen(c->name); - size_t needed = names_len + tag_len + name_len + 1; - - if (needed > names_size) { - names_size = needed * 2; - names = realloc(names, names_size); - if (!names) - die("quicksearch: realloc failed"); - } - - if (client_count > clients_size) { - clients_size = client_count * 2; - clients = realloc(clients, clients_size * sizeof(Client *)); - if (!clients) - die("quicksearch: realloc failed"); - } - - strlcpy(names + names_len, tag_str, names_size - names_len); - names_len += tag_len; - strlcpy(names + names_len, c->name, names_size - names_len); - - names_len += name_len; - names[names_len] = '\n'; - names_len++; - - clients[client_count - 1] = c; - } - } - } - - if (client_count == 0) - return; - - names[names_len - 1] = '\0'; - - char dmenu_cmd[256]; - snprintf(dmenu_cmd, sizeof(dmenu_cmd), "echo '%s' | dmenu -l 10 -i -p 'Find client:'", names); - - FILE *fp = popen(dmenu_cmd, "r"); - if (!fp) { - free(names); - free(clients); - return; - } - - char selected_name[256]; - if (fgets(selected_name, sizeof(selected_name), fp) != NULL) { - size_t len = strlen(selected_name); - if (len > 0 && selected_name[len - 1] == '\n') - selected_name[len - 1] = '\0'; - - char *client_name = strchr(selected_name, ']'); - if (client_name) { - client_name += 2; - - for (int i = 0; i < client_count; i++) { - if (strcmp(clients[i]->name, client_name) == 0) { - Client *selected_client = clients[i]; - - if (mode == 1) { - selected_client->tags = selmon->tagset[selmon->seltags]; - - if (selected_client->mon != selmon) { - detach(selected_client); - detachstack(selected_client); - selected_client->mon = selmon; - attach(selected_client); - attachstack(selected_client); - } - - focus(selected_client); - arrange(selmon); - } else { - if (selected_client->mon != selmon) - selmon = selected_client->mon; - - Arg view_arg; - view_arg.ui = selected_client->tags; - view(&view_arg); - - focus(selected_client); - } - - if (selected_client != nexttiled(selmon->clients)) { - zoom(0); - } - - break; - } - } - } - } - - pclose(fp); - free(names); - free(clients); -} |
