aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-12-27 11:43:14 +0100
committerJoe <rbo@gmx.us>2024-12-27 11:43:14 +0100
commite39b8f558d852bfd9deef2e4cacdacad681859db (patch)
tree84be79853bbbcaa3946820aa52e9d068bda40d97
parentapplied moveresize (diff)
downloaddwm-e39b8f558d852bfd9deef2e4cacdacad681859db.tar.gz
dwm-e39b8f558d852bfd9deef2e4cacdacad681859db.tar.bz2
dwm-e39b8f558d852bfd9deef2e4cacdacad681859db.tar.xz
dwm-e39b8f558d852bfd9deef2e4cacdacad681859db.tar.zst
dwm-e39b8f558d852bfd9deef2e4cacdacad681859db.zip
how fcking great
-rw-r--r--config.def.h6
-rw-r--r--dwm.c59
2 files changed, 62 insertions, 3 deletions
diff --git a/config.def.h b/config.def.h
index 07ea5ec..ced1d3c 100644
--- a/config.def.h
+++ b/config.def.h
@@ -144,7 +144,7 @@ static const Layout layouts[] = {
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
static const char *term_cmd[] = { "alacritty", NULL };
static const char *hardflip_cmd[] = { "alacritty", "-e", "hf", NULL };
-static const char *dmenucmd[] = { "dmenu_run", "-i", "-m", "0", NULL };
+static const char *dmenucmd[] = { "dmenu_run", "-i", NULL };
static const char *dmapps_cmd[] = { "/home/r_bousset/.local/bin/dmapps", NULL };
static const char *dmpc_cmd[] = { "/home/r_bousset/.local/bin/dmpc", NULL };
static const char *dmbookm_cmd[] = { "/home/r_bousset/.local/bin/dmbookm", NULL };
@@ -213,8 +213,8 @@ static const Key keys[] = {
{ MODKEY|ControlMask, XK_F9, spawn, {.v = dmkill_cmd } },
{ MODKEY|ControlMask, XK_F10, spawn, {.v = dmscrot_cmd } },
{ MODKEY|ControlMask, XK_F11, spawn, {.v = dmsearch_cmd } },
- { MODKEY|ControlMask, XK_F12, spawn, {.v = dmlog_cmd } },
- { MODKEY|ControlMask, XK_BackSpace, spawn, {.v = dmlog_cmd } },
+ { MODKEY|ControlMask, XK_F12, dmenuspawn, {.v = dmlog_cmd } },
+ { MODKEY|ControlMask, XK_BackSpace, dmenuspawn, {.v = dmlog_cmd } },
{ MODKEY, XK_BackSpace, spawn, {.v = dmpc_cmd } },
{ MODKEY|ControlMask, XK_p, spawn, {.v = dmpass_cmd } },
{ MODKEY|ControlMask|ShiftMask, XK_p, spawn, {.v = dmpass_full_cmd } },
diff --git a/dwm.c b/dwm.c
index ec5910d..c3c7d12 100644
--- a/dwm.c
+++ b/dwm.c
@@ -206,6 +206,7 @@ static void destroynotify(XEvent *e);
static void detach(Client *c);
static void detachstack(Client *c);
static Monitor *dirtomon(int dir);
+static void dmenuspawn(const Arg *arg);
static void drawbar(Monitor *m);
static void drawbars(void);
static int drawstatusbar(Monitor *m, int bh, char* text);
@@ -2662,6 +2663,64 @@ sigterm(int unused)
}
void
+dmenuspawn(const Arg *arg)
+{
+ unsigned int focused_tag;
+ int i, j;
+ struct sigaction sa;
+ char **cmd;
+
+ cmd = malloc(8 * sizeof(char*));
+ if (!cmd)
+ return;
+
+ for (i = 0; i < 8 && ((char**)arg->v)[i] != NULL; i++) {
+ cmd[i] = strdup(((char**)arg->v)[i]);
+ if (!cmd[i]) {
+ for (j = 0; j < i; j++) {
+ free(cmd[j]);
+ }
+ free(cmd);
+ return;
+ }
+ }
+ focused_tag = selmon->tagset[selmon->seltags];
+ for (j = 0; j < LENGTH(tags); j++) {
+ if (focused_tag & (1 << (j - 1))) {
+ break;
+ }
+ }
+ cmd[i] = strdup(tagsel[j - 1][1]);
+ if (!cmd[i]) {
+ for (j = 0; j < i; j++) {
+ free(cmd[j]);
+ }
+ free(cmd);
+ return;
+ }
+ cmd[i + 1] = NULL;
+ if (arg->v == dmenucmd)
+ dmenumon[0] = '0' + selmon->num;
+ if (fork() == 0) {
+ if (dpy)
+ close(ConnectionNumber(dpy));
+ setsid();
+
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+ sa.sa_handler = SIG_DFL;
+ sigaction(SIGCHLD, &sa, NULL);
+
+ execvp(((char **)cmd)[0], (char **)cmd);
+ die("dwm: execvp '%s' failed:", ((char **)cmd)[0]);
+ }
+ for (i = 0; cmd[i] != NULL; i++) {
+ free(cmd[i]);
+ }
+ free(cmd);
+}
+
+void
spawn(const Arg *arg)
{
struct sigaction sa;