diff --git a/README.md b/README.md index eabee8a..33ce704 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ philosophy. Like dwm, dwl is: - [en-keycodes](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/en-keycodes) - [genericgaps](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/genericgaps/) - [hide_vacant_tags](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/hide_vacant_tags) +- [rotatetags](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/rotatetags/rotatetags.patch) - [setupenv](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/setupenv) - [sticky](https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/sticky) - [xkb-rules-switcher](https://codeberg.org/wochap/dwl/src/branch/v0.6-b/xkb-rules-switcher/xkb-rules-switcher.patch) diff --git a/config.def.h b/config.def.h index 7a6c8dc..ad797fc 100644 --- a/config.def.h +++ b/config.def.h @@ -29,6 +29,13 @@ static uint32_t colors[][3] = { [SchemeUrg] = { 0, 0, 0x770000ff }, }; +enum { + VIEW_L = -1, + VIEW_R = 1, + SHIFT_L = -2, + SHIFT_R = 2, +} RotateTags; + /* tagging - TAGCOUNT must be no greater than 31 */ static char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; @@ -163,7 +170,11 @@ static const Key keys[] = { { MODKEY, XKB_KEY_j, focusstack, {.i = +1} }, { MODKEY, XKB_KEY_k, focusstack, {.i = -1} }, { MODKEY, XKB_KEY_i, incnmaster, {.i = +1} }, - { MODKEY, XKB_KEY_d, incnmaster, {.i = -1} }, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_i, incnmaster, {.i = -1} }, + { MODKEY, XKB_KEY_a, rotatetags, {.i = VIEW_L} }, + { MODKEY, XKB_KEY_d, rotatetags, {.i = VIEW_R} }, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_a, rotatetags, {.i = SHIFT_L} }, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_d, rotatetags, {.i = SHIFT_R} }, { MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} }, { MODKEY, XKB_KEY_l, setmfact, {.f = +0.05f} }, { MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_h, incgaps, {.i = +1 } }, diff --git a/config.h b/config.h index 08f893c..33a781f 100644 --- a/config.h +++ b/config.h @@ -19,6 +19,13 @@ static const char *fonts[] = {"inconsolata:size=11"}; /* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */ +enum { + VIEW_L = -1, + VIEW_R = 1, + SHIFT_L = -2, + SHIFT_R = 2, +} RotateTags; + /* tagging - TAGCOUNT must be no greater than 31 */ static char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8" }; @@ -182,6 +189,10 @@ static const Key keys[] = { { MODKEY, XKB_KEY_k, focusstack, {.i = -1} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_A, incnmaster, {.i = -1} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_D, incnmaster, {.i = +1} }, + { MODKEY, XKB_KEY_a, rotatetags, {.i = VIEW_L} }, + { MODKEY, XKB_KEY_d, rotatetags, {.i = VIEW_R} }, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_A, rotatetags, {.i = SHIFT_L} }, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_D, rotatetags, {.i = SHIFT_R} }, { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_a, setmfact, {.f = -0.05f} }, { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_d, setmfact, {.f = +0.05f} }, { MODKEY, XKB_KEY_w, switchxkbrule, {0} }, diff --git a/dwl.c b/dwl.c index e03c059..06336ce 100644 --- a/dwl.c +++ b/dwl.c @@ -414,6 +414,7 @@ static Monitor *xytomon(double x, double y); static void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc, LayerSurface **pl, double *nx, double *ny); static void zoom(const Arg *arg); +static void rotatetags(const Arg *arg); /* variables */ static pid_t child_pid = -1; @@ -3594,6 +3595,34 @@ zoom(const Arg *arg) arrange(selmon); } +static void +rotatetags(const Arg *arg) +{ + Arg newarg; + int i = arg->i; + int nextseltags = 0, curseltags = selmon->tagset[selmon->seltags]; + bool shift = false; + + switch(abs(i)) { + default: break; + case SHIFT_R: + shift = true; + break; + }; + + if (i > 0) + nextseltags = (curseltags << 1) | (curseltags >> (LENGTH(tags) - 1)); + else + nextseltags = (curseltags >> 1) | (curseltags << (LENGTH(tags) - 1)); + + newarg.i = nextseltags; + + if (shift) + tag(&newarg); + else + view(&newarg); +} + #ifdef XWAYLAND void activatex11(struct wl_listener *listener, void *data)