diff --git a/config.h b/config.h index 86ecc77..7bee0b0 100644 --- 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 index 8701bdb..fd73d86 100644 --- 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 index b592a67..a52ccd7 100644 --- 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); + } +}