dwm

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 01231194cc7c8a4f3ac31e2fc5d72cb0c65e68b4
parent 8cd6c7f0ea1834c14086eb3cb068c11406d4c3a2
Author: Luke Smith <luke@lukesmith.xyz>
Date:   Sun,  3 May 2020 16:08:23 -0400

super+shift+g/; to send to prev/next window

i'll merge the functions later maybe lol

Diffstat:
Mconfig.h | 8++++----
Mlarbs.mom | 4++--
Mshiftview.c | 32++++++++++++++++++++++++++++++++
3 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/config.h b/config.h @@ -164,12 +164,12 @@ static Key keys[] = { { MODKEY, XK_f, togglefullscr, {0} }, { MODKEY|ShiftMask, XK_f, setlayout, {.v = &layouts[8]} }, { MODKEY, XK_g, shiftview, { .i = -1 } }, - /* { MODKEY|ShiftMask, XK_g, shifttag, { .i = -1 } }, */ + { MODKEY|ShiftMask, XK_g, shifttag, { .i = -1 } }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, /* J and K are automatically bound above in STACKEYS */ { MODKEY, XK_l, setmfact, {.f = +0.05} }, { MODKEY, XK_semicolon, shiftview, { .i = 1 } }, - /* { MODKEY|ShiftMask, XK_semicolon, shifttag, { .i = 1 } }, */ + { MODKEY|ShiftMask, XK_semicolon, shifttag, { .i = 1 } }, { MODKEY, XK_apostrophe, togglescratch, {.ui = 1} }, /* { MODKEY|ShiftMask, XK_apostrophe, spawn, SHCMD("") }, */ { MODKEY, XK_Return, spawn, {.v = termcmd } }, @@ -200,9 +200,9 @@ static Key keys[] = { { MODKEY|ShiftMask, XK_Right, tagmon, {.i = +1 } }, { MODKEY, XK_Page_Up, shiftview, { .i = -1 } }, - /* { MODKEY|ShiftMask, XK_Page_Up, shifttag, { .i = -1 } }, */ + { MODKEY|ShiftMask, XK_Page_Up, shifttag, { .i = -1 } }, { MODKEY, XK_Page_Down, shiftview, { .i = +1 } }, - /* { MODKEY|ShiftMask, XK_Page_Down, shifttag, { .i = +1 } }, */ + { MODKEY|ShiftMask, XK_Page_Down, shifttag, { .i = +1 } }, { MODKEY, XK_Insert, spawn, SHCMD("notify-send \"📋 Clipboard contents:\" \"$(xclip -o -selection clipboard)\"") }, { MODKEY, XK_F1, spawn, SHCMD("groff -mom /usr/local/share/dwm/larbs.mom -Tpdf | zathura -") }, diff --git a/larbs.mom b/larbs.mom @@ -244,9 +244,9 @@ There are nine tags, active tags are highlighted in the top left. .ITEM \f(CWMod+Tab\fP \(en Go to previous tag (may also use \f(CW\\\fP for Tab) .ITEM -\f(CWMod+g\fP \(en Go to left tag +\f(CWMod+g\fP \(en Go to left tag (hold shift to send window there) .ITEM -\f(CWMod+;\fP \(en Go to right tag +\f(CWMod+;\fP \(en Go to right tag (hold shift to send window there) .ITEM \f(CWMod+Left\fP \(en Move to workspace to the left .ITEM diff --git a/shiftview.c b/shiftview.c @@ -34,3 +34,35 @@ shiftview(const Arg *arg) view(&a); } } + +void +shifttag(const Arg *arg) +{ + Arg a; + Client *c; + unsigned visible = 0; + int i = arg->i; + int count = 0; + int nextseltags, curseltags = selmon->tagset[selmon->seltags]; + + do { + if(i > 0) // left circular shift + nextseltags = (curseltags << i) | (curseltags >> (LENGTH(tags) - i)); + + else // right circular shift + nextseltags = curseltags >> (- i) | (curseltags << (LENGTH(tags) + i)); + + // Check if tag is visible + for (c = selmon->clients; c && !visible; c = c->next) + if (nextseltags & c->tags) { + visible = 1; + break; + } + i += arg->i; + } while (!visible && ++count < 10); + + if (count < 10) { + a.i = nextseltags; + tag(&a); + } +}