Introduction
Introduction Statistics Contact Development Disclaimer Help
dwm-shif-tools-6.2.diff - sites - public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log
Files
Refs
---
dwm-shif-tools-6.2.diff (7404B)
---
1 From d57c8508c9f26be40667d402a2daaa2b27ae759f Mon Sep 17 00:00:00 2001
2 From: explosion-mental <[email protected]>
3 Date: Wed, 11 Aug 2021 21:05:44 -0500
4 Subject: [PATCH] shift-tools - shifttag, moves the current selected clie…
5 the adjacent tag - shifttagclients, moves the current selected client t…
6 adjacent tag that has at least one client else acts as shifttag -
7 shiftview, view adjacent tag - shiftviewclients, view the closes tag th…
8 a client. If none acts as shiftview - shiftboth, shifttag and shiftvi…
9 Basically moves the window to the next/prev tag and follows it. -
10 shiftswaptags, its a shift implementation on the swaptags function (s…
11 https://github.com/moizifty/DWM-Build/blob/65379c62640788881486401a0d8c…
12 for more details), which in short 'swaps tags' (swaps all clients wit…
13 the clients on the adjacent tag). A pretty useful example of this is
14 chosing a tag empty and sending all your clients to that tag. - swapfun…
15 is the 'helper' function for the shiftswaptags. remember that these fun…
16 **shift**, which means you can go from tag 1 to 9 or 9 to 1. Also remem…
17 that the default argument is 1 and you can change it.
18
19 ---
20 config.def.h | 9 ++++
21 shift-tools.c | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++
22 2 files changed, 144 insertions(+)
23 create mode 100644 shift-tools.c
24
25 diff --git a/config.def.h b/config.def.h
26 index 1c0b587..1390d17 100644
27 --- a/config.def.h
28 +++ b/config.def.h
29 @@ -58,9 +58,14 @@ static const Layout layouts[] = {
30 static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in…
31 static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", d…
32 static const char *termcmd[] = { "st", NULL };
33 +#include "shift-tools.c"
34
35 static Key keys[] = {
36 /* modifier key function argu…
37 + { MODKEY, XK_o, shiftviewclients, { .i…
38 + { MODKEY|ShiftMask, XK_o, shiftview, …
39 + { MODKEY|ShiftMask, XK_i, shiftview, …
40 + { MODKEY, XK_i, shiftviewclients, { .…
41 { MODKEY, XK_p, spawn, {.v …
42 { MODKEY|ShiftMask, XK_Return, spawn, {.v …
43 { MODKEY, XK_b, togglebar, {0} …
44 @@ -69,6 +74,10 @@ static Key keys[] = {
45 { MODKEY, XK_i, incnmaster, {.i …
46 { MODKEY, XK_d, incnmaster, {.i …
47 { MODKEY, XK_h, setmfact, {.f …
48 + { MODKEY|ShiftMask, XK_h, shiftboth, {…
49 + { MODKEY|ControlMask, XK_h, shiftswaptags, …
50 + { MODKEY|ControlMask, XK_l, shiftswaptags, …
51 + { MODKEY|ShiftMask, XK_l, shiftboth, { .i…
52 { MODKEY, XK_l, setmfact, {.f …
53 { MODKEY, XK_Return, zoom, {0} …
54 { MODKEY, XK_Tab, view, {0} …
55 diff --git a/shift-tools.c b/shift-tools.c
56 new file mode 100644
57 index 0000000..cf130c8
58 --- /dev/null
59 +++ b/shift-tools.c
60 @@ -0,0 +1,135 @@
61 +/* Sends a window to the next/prev tag */
62 +void
63 +shifttag(const Arg *arg)
64 +{
65 + Arg shifted;
66 + shifted.ui = selmon->tagset[selmon->seltags];
67 +
68 +
69 + if (arg->i > 0) /* left circular shift */
70 + shifted.ui = ((shifted.ui << arg->i) | (shifted.ui >> (…
71 + else /* right circular shift */
72 + shifted.ui = (shifted.ui >> (- arg->i) | shifted.ui << …
73 + tag(&shifted);
74 +}
75 +/* Sends a window to the next/prev tag that has a client, else it moves…
76 +void
77 +shifttagclients(const Arg *arg)
78 +{
79 +
80 + Arg shifted;
81 + Client *c;
82 + unsigned int tagmask = 0;
83 + shifted.ui = selmon->tagset[selmon->seltags];
84 +
85 + for (c = selmon->clients; c; c = c->next)
86 + if (!(c->tags))
87 + tagmask = tagmask | c->tags;
88 +
89 +
90 + if (arg->i > 0) /* left circular shift */
91 + do {
92 + shifted.ui = (shifted.ui << arg->i)
93 + | (shifted.ui >> (LENGTH(tags) - arg->i));
94 + } while (tagmask && !(shifted.ui & tagmask));
95 + else /* right circular shift */
96 + do {
97 + shifted.ui = (shifted.ui >> (- arg->i)
98 + | shifted.ui << (LENGTH(tags) + arg->i));
99 + } while (tagmask && !(shifted.ui & tagmask));
100 + tag(&shifted);
101 +}
102 +/* Navigate to the next/prev tag */
103 +void
104 +shiftview(const Arg *arg)
105 +{
106 + Arg shifted;
107 + shifted.ui = selmon->tagset[selmon->seltags];
108 +
109 + if (arg->i > 0) /* left circular shift */
110 + shifted.ui = (shifted.ui << arg->i) | (shifted.ui >> (L…
111 + else /* right circular shift */
112 + shifted.ui = (shifted.ui >> (- arg->i) | shifted.ui << …
113 + view(&shifted);
114 +}
115 +/* Navigate to the next/prev tag that has a client, else moves it to th…
116 +void
117 +shiftviewclients(const Arg *arg)
118 +{
119 + Arg shifted;
120 + Client *c;
121 + unsigned int tagmask = 0;
122 + shifted.ui = selmon->tagset[selmon->seltags];
123 +
124 + for (c = selmon->clients; c; c = c->next)
125 + if (!(c->tags))
126 + tagmask = tagmask | c->tags;
127 +
128 +
129 + if (arg->i > 0) /* left circular shift */
130 + do {
131 + shifted.ui = (shifted.ui << arg->i)
132 + | (shifted.ui >> (LENGTH(tags) - arg->i));
133 + } while (tagmask && !(shifted.ui & tagmask));
134 + else /* right circular shift */
135 + do {
136 + shifted.ui = (shifted.ui >> (- arg->i)
137 + | shifted.ui << (LENGTH(tags) + arg->i));
138 + } while (tagmask && !(shifted.ui & tagmask));
139 + view(&shifted);
140 +}
141 +/* move the current active window to the next/prev tag and view it. Mor…
142 +void
143 +shiftboth(const Arg *arg)
144 +{
145 + Arg shifted;
146 + shifted.ui = selmon->tagset[selmon->seltags];
147 +
148 + if (arg->i > 0) /* left circular shift */
149 + shifted.ui = ((shifted.ui << arg->i) | (shifted.ui >> (…
150 + else /* right circular shift */
151 + shifted.ui = ((shifted.ui >> (- arg->i) | shifted.ui <<…
152 + tag(&shifted);
153 + view(&shifted);
154 +}
155 +//helper function for shiftswaptags.
156 +//see: https://github.com/moizifty/DWM-Build/blob/65379c626407888814864…
157 +void
158 +swaptags(const Arg *arg)
159 +{
160 + Client *c;
161 + unsigned int newtag = arg->ui & TAGMASK;
162 + unsigned int curtag = selmon->tagset[selmon->seltags];
163 +
164 + if (newtag == curtag || !curtag || (curtag & (curtag-1)))
165 + return;
166 +
167 + for (c = selmon->clients; c != NULL; c = c->next) {
168 + if ((c->tags & newtag) || (c->tags & curtag))
169 + c->tags ^= curtag ^ newtag;
170 +
171 + if (!c->tags)
172 + c->tags = newtag;
173 + }
174 +
175 + //move to the swaped tag
176 + //selmon->tagset[selmon->seltags] = newtag;
177 +
178 + focus(NULL);
179 + arrange(selmon);
180 +}
181 +/* swaps "tags" (all the clients) with the next/prev tag. */
182 +void
183 +shiftswaptags(const Arg *arg)
184 +{
185 + Arg shifted;
186 + shifted.ui = selmon->tagset[selmon->seltags];
187 +
188 + if (arg->i > 0) /* left circular shift */
189 + shifted.ui = ((shifted.ui << arg->i) | (shifted.ui >> (…
190 + else /* right circular shift */
191 + shifted.ui = ((shifted.ui >> (- arg->i) | shifted.ui <<…
192 + swaptags(&shifted);
193 + // uncomment if you also want to "go" (view) the tag where the …
194 + //view(&shifted);
195 +}
196 --
197 2.32.0
198
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.