diff options
| author | LM-LCL <hello@exaltedelite.club> | 2024-11-20 09:48:01 +0100 |
|---|---|---|
| committer | LM-LCL <hello@exaltedelite.club> | 2024-11-20 09:48:01 +0100 |
| commit | 7267c642c64a79f33c425a15e78892554b38f6d4 (patch) | |
| tree | cf406ea6caa977ae66528cb8bf5509f492c7ce70 | |
| parent | d7b0b971266fb97f3170daa9ece88148d4793116 (diff) | |
Rofi
| -rw-r--r-- | config.def.h | 4 | ||||
| -rw-r--r-- | config.h | 14 | ||||
| -rw-r--r-- | dwm.1 | 12 | ||||
| -rw-r--r-- | dwm.c | 67 | ||||
| -rw-r--r-- | patches/dwm-focusadjacenttag-6.3.diff | 115 | ||||
| -rw-r--r-- | patches/dwm-focusonnetactive-6.2.diff | 57 |
6 files changed, 258 insertions, 11 deletions
diff --git a/config.def.h b/config.def.h index bb24efa..7873a78 100644 --- a/config.def.h +++ b/config.def.h @@ -104,6 +104,10 @@ static const Key keys[] = { { MODKEY, XK_period, focusmon, {.i = +1 } }, { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, ++ { MODKEY, XK_Left, viewtoleft, {0} }, ++ { MODKEY, XK_Right, viewtoright, {0} }, ++ { MODKEY|ShiftMask, XK_Left, tagtoleft, {0} }, ++ { MODKEY|ShiftMask, XK_Right, tagtoright, {0} }, { Mod1Mask, XK_Tab, altTabStart, {.i = 1} }, { Mod1Mask, XK_grave, altTabStart, {.i = 0} }, TAGKEYS( XK_1, 0) @@ -73,20 +73,20 @@ static const Layout layouts[] = { /* commands */ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_white, "-sb", col_gray2, "-sf", col_white, NULL }; +static const char *roficmd[] = { "rofi", "-show", "drun" }; +static const char *rofitab[] = { "rofi", "-show", "window" }; static const char *termcmd[] = { "st", NULL }; #include "movestack.c" static const Key keys[] = { /* modifier key function argument */ - { MODKEY, XK_p, spawn, {.v = dmenucmd} }, + { MODKEY, XK_p, spawn, {.v = roficmd} }, { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd} }, { MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_j, focusstack, {.i = +1} }, { MODKEY, XK_k, focusstack, {.i = -1} }, { MODKEY, XK_i, incnmaster, {.i = +1} }, { MODKEY, XK_d, incnmaster, {.i = -1} }, - { MODKEY, XK_h, setmfact, {.f = -0.05} }, - { MODKEY, XK_l, setmfact, {.f = +0.05} }, { MODKEY|ShiftMask, XK_j, movestack, {.i = +1} }, { MODKEY|ShiftMask, XK_k, movestack, {.i = -1} }, { MODKEY, XK_Return, zoom, {0} }, @@ -102,8 +102,12 @@ static const Key keys[] = { { MODKEY, XK_period, focusmon, {.i = +1} }, { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1} }, { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1} }, - { MODKEY, XK_Tab, altTabStart, {.i = 1} }, - { MODKEY, XK_grave, altTabStart, {.i = 0} }, + { MODKEY, XK_Tab, spawn, {.v = rofitab} }, + { MODKEY, XK_grave, spawn, {.v = rofitab} }, + { MODKEY, XK_h, viewtoleft, {0} }, + { MODKEY, XK_l, viewtoright, {0} }, + { MODKEY|ShiftMask, XK_h, tagtoleft, {0} }, + { MODKEY|ShiftMask, XK_l, tagtoright, {0} }, TAGKEYS( XK_1, 0 ) TAGKEYS( XK_2, 1 ) TAGKEYS( XK_3, 2 ) @@ -80,6 +80,18 @@ Send focused window to previous screen, if any. .B Mod1\-Shift\-. Send focused window to next screen, if any. .TP +.B Mod1\-Right +Focus tag on the right, if any. +.TP +.B Mod1\-Left +Focus tag on the left, if any. +.TP +.B Mod1\-Shift\-Right +Send focused window to tag on the right, if any. +.TP +.B Mod1\-Shift\-Left +Send focused window to tag on the left, if any. +.TP .B Mod1\-b Toggles bar on and off. .TP @@ -247,6 +247,8 @@ static void spawn(const Arg *arg); static Monitor *systraytomon(Monitor *m); static void tag(const Arg *arg); static void tagmon(const Arg *arg); +static void tagtoleft(const Arg *arg); +static void tagtoright(const Arg *arg); static void tile(Monitor *m); static void togglebar(const Arg *arg); static void togglefloating(const Arg *arg); @@ -269,6 +271,8 @@ static void updatetitle(Client *c); static void updatewindowtype(Client *c); static void updatewmhints(Client *c); static void view(const Arg *arg); +static void viewtoleft(const Arg *arg); +static void viewtoright(const Arg *arg); static Client *wintoclient(Window w); static Monitor *wintomon(Window w); static Client *wintosystrayicon(Window w); @@ -599,6 +603,7 @@ clientmessage(XEvent *e) XSetWindowAttributes swa; XClientMessageEvent *cme = &e->xclient; Client *c = wintoclient(cme->window); + unsigned int i; if (showsystray && cme->window == systray->win && cme->message_type == netatom[NetSystemTrayOP]) { /* add systray icons */ @@ -655,8 +660,14 @@ clientmessage(XEvent *e) setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */ || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen))); } else if (cme->message_type == netatom[NetActiveWindow]) { - if (c != selmon->sel && !c->isurgent) - seturgent(c, 1); + for (i = 0; i < LENGTH(tags) && !((1 << i) & c->tags); i++); + if (i < LENGTH(tags)) { + const Arg a = {.ui = 1 << i}; + selmon = c->mon; + view(&a); + focus(c); + restack(selmon); + } } } @@ -1936,12 +1947,12 @@ altTabShift() focus(selmon->altsnext[selmon->altTabN]); } } - + /* redraw tab */ XRaiseWindow(dpy, selmon->tabwin); drawTab(selmon->nTabs, 0, selmon); } - + void altTabShiftClass() { @@ -1970,7 +1981,7 @@ altTabEnd() /* * move all clients between 1st and choosen position, - * one down in stack and put choosen client to the first position + * one down in stack and put choosen client to the first position * so they remain in right order for the next time that alt-tab is used */ if (selmon->nTabs > 1) { @@ -2169,7 +2180,7 @@ altTabStart(const Arg *arg) else altTabClass(); } - + } } } @@ -2207,6 +2218,28 @@ tagmon(const Arg *arg) } void +tagtoleft(const Arg *arg) { + if(selmon->sel != NULL + && __builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 + && selmon->tagset[selmon->seltags] > 1) { + selmon->sel->tags >>= 1; + focus(NULL); + arrange(selmon); + } +} + +void +tagtoright(const Arg *arg) { + if(selmon->sel != NULL + && __builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 + && selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) { + selmon->sel->tags <<= 1; + focus(NULL); + arrange(selmon); + } +} + +void tile(Monitor *m) { unsigned int i, n, h, mw, my, ty; @@ -2788,6 +2821,28 @@ view(const Arg *arg) arrange(selmon); } +void +viewtoleft(const Arg *arg) { + if(__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 + && selmon->tagset[selmon->seltags] > 1) { + selmon->seltags ^= 1; /* toggle sel tagset */ + selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] >> 1; + focus(NULL); + arrange(selmon); + } +} + +void +viewtoright(const Arg *arg) { + if(__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 + && selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) { + selmon->seltags ^= 1; /* toggle sel tagset */ + selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] << 1; + focus(NULL); + arrange(selmon); + } +} + Client * wintoclient(Window w) { diff --git a/patches/dwm-focusadjacenttag-6.3.diff b/patches/dwm-focusadjacenttag-6.3.diff new file mode 100644 index 0000000..142b57e --- /dev/null +++ b/patches/dwm-focusadjacenttag-6.3.diff @@ -0,0 +1,115 @@ +diff -up a/config.def.h b/config.def.h +--- a/config.def.h 2014-06-23 18:04:29.536917000 +0200 ++++ b/config.def.h 2014-06-24 08:15:51.857173332 +0200 +@@ -74,6 +74,10 @@ static Key keys[] = { + { MODKEY, XK_period, focusmon, {.i = +1 } }, + { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, + { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, ++ { MODKEY, XK_Left, viewtoleft, {0} }, ++ { MODKEY, XK_Right, viewtoright, {0} }, ++ { MODKEY|ShiftMask, XK_Left, tagtoleft, {0} }, ++ { MODKEY|ShiftMask, XK_Right, tagtoright, {0} }, + TAGKEYS( XK_1, 0) + TAGKEYS( XK_2, 1) + TAGKEYS( XK_3, 2) +diff -up a/dwm.1 b/dwm.1 +--- a/dwm.1 2014-06-23 18:04:29.532917821 +0200 ++++ b/dwm.1 2014-06-23 21:52:54.095867809 +0200 +@@ -71,6 +71,18 @@ Send focused window to previous screen, + .B Mod1\-Shift\-. + Send focused window to next screen, if any. + .TP ++.B Mod1\-Right ++Focus tag on the right, if any. ++.TP ++.B Mod1\-Left ++Focus tag on the left, if any. ++.TP ++.B Mod1\-Shift\-Right ++Send focused window to tag on the right, if any. ++.TP ++.B Mod1\-Shift\-Left ++Send focused window to tag on the left, if any. ++.TP + .B Mod1\-b + Toggles bar on and off. + .TP +diff -up a/dwm.c b/dwm.c +--- a/dwm.c 2014-06-23 18:04:29.532917821 +0200 ++++ b/dwm.c 2014-06-24 08:17:40.921714154 +0200 +@@ -226,6 +226,8 @@ static void sigchld(int unused); + static void spawn(const Arg *arg); + static void tag(const Arg *arg); + static void tagmon(const Arg *arg); ++static void tagtoleft(const Arg *arg); ++static void tagtoright(const Arg *arg); + static void tile(Monitor *); + static void togglebar(const Arg *arg); + static void togglefloating(const Arg *arg); +@@ -245,6 +247,8 @@ static void updatewindowtype(Client *c); + static void updatewindowtype(Client *c); + static void updatewmhints(Client *c); + static void view(const Arg *arg); ++static void viewtoleft(const Arg *arg); ++static void viewtoright(const Arg *arg); + static Client *wintoclient(Window w); + static Monitor *wintomon(Window w); + static int xerror(Display *dpy, XErrorEvent *ee); +@@ -1690,6 +1694,28 @@ tagmon(const Arg *arg) { + sendmon(selmon->sel, dirtomon(arg->i)); + } + ++void ++tagtoleft(const Arg *arg) { ++ if(selmon->sel != NULL ++ && __builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 ++ && selmon->tagset[selmon->seltags] > 1) { ++ selmon->sel->tags >>= 1; ++ focus(NULL); ++ arrange(selmon); ++ } ++} ++ ++void ++tagtoright(const Arg *arg) { ++ if(selmon->sel != NULL ++ && __builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 ++ && selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) { ++ selmon->sel->tags <<= 1; ++ focus(NULL); ++ arrange(selmon); ++ } ++} ++ + void + tile(Monitor *m) + { +@@ -2052,6 +2078,28 @@ view(const Arg *arg) { + arrange(selmon); + } + ++void ++viewtoleft(const Arg *arg) { ++ if(__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 ++ && selmon->tagset[selmon->seltags] > 1) { ++ selmon->seltags ^= 1; /* toggle sel tagset */ ++ selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] >> 1; ++ focus(NULL); ++ arrange(selmon); ++ } ++} ++ ++void ++viewtoright(const Arg *arg) { ++ if(__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 ++ && selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) { ++ selmon->seltags ^= 1; /* toggle sel tagset */ ++ selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] << 1; ++ focus(NULL); ++ arrange(selmon); ++ } ++} ++ + Client * + wintoclient(Window w) + { diff --git a/patches/dwm-focusonnetactive-6.2.diff b/patches/dwm-focusonnetactive-6.2.diff new file mode 100644 index 0000000..5d358d2 --- /dev/null +++ b/patches/dwm-focusonnetactive-6.2.diff @@ -0,0 +1,57 @@ +From 286ca3bb1af08b452bf8140abcc23d4ef61baaa2 Mon Sep 17 00:00:00 2001 +From: bakkeby <bakkeby@gmail.com> +Date: Tue, 7 Apr 2020 12:33:04 +0200 +Subject: [PATCH] Activate a window in response to _NET_ACTIVE_WINDOW + +By default, dwm response to client requests to _NET_ACTIVE_WINDOW client +messages by setting the urgency bit on the named window. + +This patch activates the window instead. + +Both behaviours are legitimate according to +https://specifications.freedesktop.org/wm-spec/wm-spec-latest.html#idm140200472702304 + +One should decide which of these one should perform based on the message +senders' untestable claims that it represents the end-user. Setting the +urgency bit is the conservative decision. This patch implements the more +trusting alternative. + +It also allows dwm to work with `wmctrl -a` and other external window +management utilities + +--- + dwm.c | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/dwm.c b/dwm.c +index 4465af1..3919d47 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -514,6 +514,7 @@ clientmessage(XEvent *e) + { + XClientMessageEvent *cme = &e->xclient; + Client *c = wintoclient(cme->window); ++ unsigned int i; + + if (!c) + return; +@@ -523,8 +524,14 @@ clientmessage(XEvent *e) + setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */ + || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen))); + } else if (cme->message_type == netatom[NetActiveWindow]) { +- if (c != selmon->sel && !c->isurgent) +- seturgent(c, 1); ++ for (i = 0; i < LENGTH(tags) && !((1 << i) & c->tags); i++); ++ if (i < LENGTH(tags)) { ++ const Arg a = {.ui = 1 << i}; ++ selmon = c->mon; ++ view(&a); ++ focus(c); ++ restack(selmon); ++ } + } + } + +-- +2.17.1 + |
